From patchwork Sat Sep 9 14:18:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 721126 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1682EEB580 for ; Sat, 9 Sep 2023 16:25:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230171AbjIIQZQ (ORCPT ); Sat, 9 Sep 2023 12:25:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346347AbjIIOT2 (ORCPT ); Sat, 9 Sep 2023 10:19:28 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 672E3CF4 for ; Sat, 9 Sep 2023 07:18:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694269111; 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: in-reply-to:in-reply-to:references:references; bh=HzqZJtWejVodVTPKo9Ws7yQdF9+fdIi5BOKy7A68lHY=; b=ESOeIR0E79VTkxCw2aXoW+3lxnkE8Sv+L2cmDmZbV2NsYOJZSe3hPlCb/A2O2TfMVURDT1 DAE1X+qYgmHC0NYfvJE06QzKWkXRYNUowrD/RToF9PjRK0QQsbxNleFncUlSFc7tjnpWYr 6pv6eDBzBfzeDyM5mrE8v2jv1bUpZhk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-202-xSrNr5BuPkOcRXu1YLRzRA-1; Sat, 09 Sep 2023 10:18:25 -0400 X-MC-Unique: xSrNr5BuPkOcRXu1YLRzRA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 99DBC8ABBC9; Sat, 9 Sep 2023 14:18:24 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8069414171B6; Sat, 9 Sep 2023 14:18:23 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mika Westerberg , Andy Shevchenko , Bartosz Golaszewski , Linus Walleij Cc: Hans de Goede , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [PATCH 1/8] gpiolib: acpi: Check if a GPIO is listed in ignore_interrupt earlier Date: Sat, 9 Sep 2023 16:18:09 +0200 Message-ID: <20230909141816.58358-2-hdegoede@redhat.com> In-Reply-To: <20230909141816.58358-1-hdegoede@redhat.com> References: <20230909141816.58358-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org In some cases where a broken AEI is present for a GPIO and the GPIO is listed in the ignore_interrupt list to avoid the broken event handler, the kernel may want to use the GPIO for another purpose. Before this change trying to use such a GPIO for another purpose would fail, because the ignore_interrupt list was only checked after the acpi_request_own_gpiod() call, causing the GPIO to already be claimed even though it is listed in the ignore_interrupt list. Fix this by moving the ignore_interrupt list to above the acpi_request_own_gpiod() call. Signed-off-by: Hans de Goede Reviewed-by: Andy Shevchenko Reviewed-by: Mika Westerberg Acked-by: Bartosz Golaszewski --- drivers/gpio/gpiolib-acpi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 97496c0f9133..80b9650a2424 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -437,6 +437,11 @@ static acpi_status acpi_gpiochip_alloc_event(struct acpi_resource *ares, if (!handler) return AE_OK; + if (acpi_gpio_in_ignore_list(ignore_interrupt, dev_name(chip->parent), pin)) { + dev_info(chip->parent, "Ignoring interrupt on pin %u\n", pin); + return AE_OK; + } + desc = acpi_request_own_gpiod(chip, agpio, 0, "ACPI:Event"); if (IS_ERR(desc)) { dev_err(chip->parent, @@ -461,11 +466,6 @@ static acpi_status acpi_gpiochip_alloc_event(struct acpi_resource *ares, goto fail_unlock_irq; } - if (acpi_gpio_in_ignore_list(ignore_interrupt, dev_name(chip->parent), pin)) { - dev_info(chip->parent, "Ignoring interrupt on pin %u\n", pin); - return AE_OK; - } - event = kzalloc(sizeof(*event), GFP_KERNEL); if (!event) goto fail_unlock_irq; From patchwork Sat Sep 9 14:18:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 721236 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9A40EEB581 for ; Sat, 9 Sep 2023 16:25:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231154AbjIIQZR (ORCPT ); Sat, 9 Sep 2023 12:25:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346349AbjIIOT2 (ORCPT ); Sat, 9 Sep 2023 10:19:28 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8DB8CE1 for ; Sat, 9 Sep 2023 07:18:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694269108; 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: in-reply-to:in-reply-to:references:references; bh=rnxkLsCINqMPfSaGEWxFyft4/YO//SJ+C30Us/G2fno=; b=Mf1ymmOhA7Bp402QZvriM1utd7mIM9vKl9jSk6Fe1COEZ3XrVm1EFyE+VUOv+aGB9P3jaJ XlxjxZ60I8lpPfrVwz/hWf+O+10GVtkQA3+YouXSN125XNEs/6QGSHPxY/vINI37js7z8R djuFez9FVyGcmLOGzhhZjZoU8/myBso= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-517-_0qrgjEiO0OCDhaD-gb5pg-1; Sat, 09 Sep 2023 10:18:26 -0400 X-MC-Unique: _0qrgjEiO0OCDhaD-gb5pg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E43F43C02536; Sat, 9 Sep 2023 14:18:25 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAF0614171B6; Sat, 9 Sep 2023 14:18:24 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mika Westerberg , Andy Shevchenko , Bartosz Golaszewski , Linus Walleij Cc: Hans de Goede , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [PATCH 2/8] gpiolib: acpi: Add a ignore interrupt quirk for Peaq C1010 Date: Sat, 9 Sep 2023 16:18:10 +0200 Message-ID: <20230909141816.58358-3-hdegoede@redhat.com> In-Reply-To: <20230909141816.58358-1-hdegoede@redhat.com> References: <20230909141816.58358-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org On the Peaq C1010 2-in-1 INT33FC:00 pin 3 is connected to a "dolby" button. At the ACPI level an _AEI event-handler is connected which sets an ACPI variable to 1 on both edges. This variable can be polled + cleared to 0 using WMI. Since the variable is set on both edges the WMI interface is pretty useless even when polling. So instead of writing a custom WMI driver for this the x86-android-tablets code instantiates a gpio-keys platform device for the "dolby" button. Add an ignore_interrupt quirk for INT33FC:00 pin 3 on the Peaq C1010, so that it is not seen as busy when the gpio-keys driver requests it. Note this replaces a hack in x86-android-tablets where it would call acpi_gpiochip_free_interrupts() on the INT33FC:00 GPIO controller. acpi_gpiochip_free_interrupts() is considered private (internal) gpiolib API so x86-android-tablets should stop using it. Signed-off-by: Hans de Goede Reviewed-by: Andy Shevchenko Reviewed-by: Mika Westerberg Acked-by: Bartosz Golaszewski --- drivers/gpio/gpiolib-acpi.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 80b9650a2424..583ac5da9d41 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -1654,6 +1654,26 @@ static const struct dmi_system_id gpiolib_acpi_quirks[] __initconst = { .ignore_wake = "SYNA1202:00@16", }, }, + { + /* + * On the Peaq C1010 2-in-1 INT33FC:00 pin 3 is connected to + * a "dolby" button. At the ACPI level an _AEI event-handler + * is connected which sets an ACPI variable to 1 on both + * edges. This variable can be polled + cleared to 0 using + * WMI. But since the variable is set on both edges the WMI + * interface is pretty useless even when polling. + * So instead the x86-android-tablets code instantiates + * a gpio-keys platform device for it. + * Ignore the _AEI handler for the pin, so that it is not busy. + */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "PEAQ"), + DMI_MATCH(DMI_PRODUCT_NAME, "PEAQ PMM C1010 MD99187"), + }, + .driver_data = &(struct acpi_gpiolib_dmi_quirk) { + .ignore_interrupt = "INT33FC:00@3", + }, + }, {} /* Terminating entry */ }; From patchwork Sat Sep 9 14:18:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 721234 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9AB1EEB59D for ; Sat, 9 Sep 2023 16:25:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231882AbjIIQZV (ORCPT ); Sat, 9 Sep 2023 12:25:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346348AbjIIOT2 (ORCPT ); Sat, 9 Sep 2023 10:19:28 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3B26CF2 for ; Sat, 9 Sep 2023 07:18:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694269111; 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: in-reply-to:in-reply-to:references:references; bh=uhKLN8srrjXbTAcvVQEFoGKbRCm1ME9oMKYTdW32b3E=; b=Iy0rQbSE6Ri3CrBV3Sofhjkphe8DiikRrBsD88ht6Rv7110c5L/S/03pXu+dDRWMTbEMsZ SY7G9dPFClaRrQGZWhckjUC8baAvpn1coFyl4rcQ289MxZ4hFKzzpyZuY7XYVSfdCtWGYl O3WhJ9L6n4CKWzX/GR/T759CHKL+gtk= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-496-9lTgI2Y_Mraxbg-ctgLkhQ-1; Sat, 09 Sep 2023 10:18:27 -0400 X-MC-Unique: 9lTgI2Y_Mraxbg-ctgLkhQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3A5F829AA2C2; Sat, 9 Sep 2023 14:18:27 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 21E0814171B6; Sat, 9 Sep 2023 14:18:26 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mika Westerberg , Andy Shevchenko , Bartosz Golaszewski , Linus Walleij Cc: Hans de Goede , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [PATCH 3/8] platform/x86: x86-android-tablets: Remove invalid_aei_gpiochip from Peaq C1010 Date: Sat, 9 Sep 2023 16:18:11 +0200 Message-ID: <20230909141816.58358-4-hdegoede@redhat.com> In-Reply-To: <20230909141816.58358-1-hdegoede@redhat.com> References: <20230909141816.58358-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Remove the invalid_aei_gpiochip setting from the x86_dev_info for the Peaq C1010. This is no longer necessary since there now is a quirk to ignore the "dolby" button GPIO in gpiolib_acpi_quirks[] in drivers/gpio/gpiolib-acpi.c . Signed-off-by: Hans de Goede Reviewed-by: Bartosz Golaszewski --- drivers/platform/x86/x86-android-tablets/other.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/platform/x86/x86-android-tablets/other.c b/drivers/platform/x86/x86-android-tablets/other.c index e79549c6aae1..621ca1e54d1f 100644 --- a/drivers/platform/x86/x86-android-tablets/other.c +++ b/drivers/platform/x86/x86-android-tablets/other.c @@ -505,11 +505,6 @@ static const struct x86_gpio_button peaq_c1010_button __initconst = { const struct x86_dev_info peaq_c1010_info __initconst = { .gpio_button = &peaq_c1010_button, .gpio_button_count = 1, - /* - * Move the ACPI event handler used by the broken WMI interface out of - * the way. This is the only event handler on INT33FC:00. - */ - .invalid_aei_gpiochip = "INT33FC:00", }; /* From patchwork Sat Sep 9 14:18:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 721233 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C094EE49BF for ; Sat, 9 Sep 2023 16:25:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232521AbjIIQZY (ORCPT ); Sat, 9 Sep 2023 12:25:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230128AbjIIOUN (ORCPT ); Sat, 9 Sep 2023 10:20:13 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07963E43 for ; Sat, 9 Sep 2023 07:18:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694269114; 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: in-reply-to:in-reply-to:references:references; bh=H71Ul7/l9XDQeRiP1W3YTZ1vWpoRPOuryOrX9nxlvNU=; b=QFd4D3Ztvu43sLUc5Q0jxpgnkbR4P2eB6Ear0T/rNmr6MV/cVT0fu0pRv8RwM/gvSxj1xd 1RXyHqI+h4VWdjkwhTQfIcijfScSAMUF0i3SDFiLKURIqtN1WFYNJ8B0aQX6CV026rw2QV p/5AzpWRFqYLu9S3ebRK5Ms1HmqwR1U= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-549-RkePu_QCOxaay6fYA0ud4Q-1; Sat, 09 Sep 2023 10:18:29 -0400 X-MC-Unique: RkePu_QCOxaay6fYA0ud4Q-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 91DBD8631D8; Sat, 9 Sep 2023 14:18:28 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C51514171B6; Sat, 9 Sep 2023 14:18:27 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mika Westerberg , Andy Shevchenko , Bartosz Golaszewski , Linus Walleij Cc: Hans de Goede , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [PATCH 4/8] platform/x86: x86-android-tablets: Remove invalid_aei_gpiochip support Date: Sat, 9 Sep 2023 16:18:12 +0200 Message-ID: <20230909141816.58358-5-hdegoede@redhat.com> In-Reply-To: <20230909141816.58358-1-hdegoede@redhat.com> References: <20230909141816.58358-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org x86_dev_info.invalid_aei_gpiochip is no longer used by any boards and the x86-android-tablets code should not use the gpiolib private acpi_gpiochip_free_interrupts() function. Reported-by: Bartosz Golaszewski Closes: https://lore.kernel.org/platform-driver-x86/20230905185309.131295-12-brgl@bgdev.pl/ Signed-off-by: Hans de Goede --- drivers/platform/x86/x86-android-tablets/core.c | 15 --------------- .../x86/x86-android-tablets/x86-android-tablets.h | 1 - 2 files changed, 16 deletions(-) diff --git a/drivers/platform/x86/x86-android-tablets/core.c b/drivers/platform/x86/x86-android-tablets/core.c index 2fd6060a31bb..ab8cf22ac5da 100644 --- a/drivers/platform/x86/x86-android-tablets/core.c +++ b/drivers/platform/x86/x86-android-tablets/core.c @@ -259,7 +259,6 @@ static __init int x86_android_tablet_init(void) { const struct x86_dev_info *dev_info; const struct dmi_system_id *id; - struct gpio_chip *chip; int i, ret = 0; id = dmi_first_match(x86_android_tablet_ids); @@ -268,20 +267,6 @@ static __init int x86_android_tablet_init(void) dev_info = id->driver_data; - /* - * The broken DSDTs on these devices often also include broken - * _AEI (ACPI Event Interrupt) handlers, disable these. - */ - if (dev_info->invalid_aei_gpiochip) { - chip = gpiochip_find(dev_info->invalid_aei_gpiochip, - gpiochip_find_match_label); - if (!chip) { - pr_err("error cannot find GPIO chip %s\n", dev_info->invalid_aei_gpiochip); - return -ENODEV; - } - acpi_gpiochip_free_interrupts(chip); - } - /* * Since this runs from module_init() it cannot use -EPROBE_DEFER, * instead pre-load any modules which are listed as requirements. diff --git a/drivers/platform/x86/x86-android-tablets/x86-android-tablets.h b/drivers/platform/x86/x86-android-tablets/x86-android-tablets.h index e46e1128acc8..bf97fb84c0d4 100644 --- a/drivers/platform/x86/x86-android-tablets/x86-android-tablets.h +++ b/drivers/platform/x86/x86-android-tablets/x86-android-tablets.h @@ -66,7 +66,6 @@ struct x86_gpio_button { }; struct x86_dev_info { - char *invalid_aei_gpiochip; const char * const *modules; const struct software_node *bat_swnode; struct gpiod_lookup_table * const *gpiod_lookup_tables; From patchwork Sat Sep 9 14:18:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 721125 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D97B7EEB580 for ; Sat, 9 Sep 2023 16:25:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231480AbjIIQZS (ORCPT ); Sat, 9 Sep 2023 12:25:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346382AbjIIOUN (ORCPT ); Sat, 9 Sep 2023 10:20:13 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 561AFE40 for ; Sat, 9 Sep 2023 07:18:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694269113; 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: in-reply-to:in-reply-to:references:references; bh=SEiYzenJ2v0uacOfeS9KSCDfwh4ycnROiWeTaaakKS0=; b=MHWMtfWPiaC1kveUz+ARx5kwaJ25bU7qmayFHwLaiaYeyCExJ2Pzdhsny0AQXseF+ZNoKr x7+M1AYbJfpAXjwsyLg6DulHGxi5TU2leobFTzN3mE+8w1LIGBcW0rkST7eIJSX26bsxkc 1cSYbxLRnZp5HjR47EvrfUyS018+mHw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-553-ynz5StlFOyG5HXbDUadR8g-1; Sat, 09 Sep 2023 10:18:30 -0400 X-MC-Unique: ynz5StlFOyG5HXbDUadR8g-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DD080803C96; Sat, 9 Sep 2023 14:18:29 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id C31C414171B6; Sat, 9 Sep 2023 14:18:28 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mika Westerberg , Andy Shevchenko , Bartosz Golaszewski , Linus Walleij Cc: Hans de Goede , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [PATCH 5/8] platform/x86: x86-android-tablets: Create a platform_device from module_init() Date: Sat, 9 Sep 2023 16:18:13 +0200 Message-ID: <20230909141816.58358-6-hdegoede@redhat.com> In-Reply-To: <20230909141816.58358-1-hdegoede@redhat.com> References: <20230909141816.58358-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Create a platform_device from module_init() and change x86_android_tablet_init() / cleanup() into platform_device probe() and remove() functions. This is a preparation patch for refactoring x86_android_tablet_get_gpiod() to no longer use gpiolib private functions like gpiochip_find(). Signed-off-by: Hans de Goede --- .../platform/x86/x86-android-tablets/core.c | 57 ++++++++++++++----- 1 file changed, 44 insertions(+), 13 deletions(-) diff --git a/drivers/platform/x86/x86-android-tablets/core.c b/drivers/platform/x86/x86-android-tablets/core.c index ab8cf22ac5da..3d3101b2848f 100644 --- a/drivers/platform/x86/x86-android-tablets/core.c +++ b/drivers/platform/x86/x86-android-tablets/core.c @@ -25,6 +25,8 @@ #include "../../../gpio/gpiolib.h" #include "../../../gpio/gpiolib-acpi.h" +static struct platform_device *x86_android_tablet_device; + static int gpiochip_find_match_label(struct gpio_chip *gc, void *data) { return gc->label && !strcmp(gc->label, data); @@ -224,7 +226,7 @@ static __init int x86_instantiate_serdev(const struct x86_serdev_info *info, int return ret; } -static void x86_android_tablet_cleanup(void) +static void x86_android_tablet_remove(struct platform_device *pdev) { int i; @@ -255,7 +257,7 @@ static void x86_android_tablet_cleanup(void) software_node_unregister(bat_swnode); } -static __init int x86_android_tablet_init(void) +static __init int x86_android_tablet_probe(struct platform_device *pdev) { const struct x86_dev_info *dev_info; const struct dmi_system_id *id; @@ -266,6 +268,8 @@ static __init int x86_android_tablet_init(void) return -ENODEV; dev_info = id->driver_data; + /* Allow x86_android_tablet_device use before probe() exits */ + x86_android_tablet_device = pdev; /* * Since this runs from module_init() it cannot use -EPROBE_DEFER, @@ -288,7 +292,7 @@ static __init int x86_android_tablet_init(void) if (dev_info->init) { ret = dev_info->init(); if (ret < 0) { - x86_android_tablet_cleanup(); + x86_android_tablet_remove(pdev); return ret; } exit_handler = dev_info->exit; @@ -296,7 +300,7 @@ static __init int x86_android_tablet_init(void) i2c_clients = kcalloc(dev_info->i2c_client_count, sizeof(*i2c_clients), GFP_KERNEL); if (!i2c_clients) { - x86_android_tablet_cleanup(); + x86_android_tablet_remove(pdev); return -ENOMEM; } @@ -304,7 +308,7 @@ static __init int x86_android_tablet_init(void) for (i = 0; i < i2c_client_count; i++) { ret = x86_instantiate_i2c_client(dev_info, i); if (ret < 0) { - x86_android_tablet_cleanup(); + x86_android_tablet_remove(pdev); return ret; } } @@ -312,7 +316,7 @@ static __init int x86_android_tablet_init(void) /* + 1 to make space for (optional) gpio_keys_button pdev */ pdevs = kcalloc(dev_info->pdev_count + 1, sizeof(*pdevs), GFP_KERNEL); if (!pdevs) { - x86_android_tablet_cleanup(); + x86_android_tablet_remove(pdev); return -ENOMEM; } @@ -320,14 +324,14 @@ static __init int x86_android_tablet_init(void) for (i = 0; i < pdev_count; i++) { pdevs[i] = platform_device_register_full(&dev_info->pdev_info[i]); if (IS_ERR(pdevs[i])) { - x86_android_tablet_cleanup(); + x86_android_tablet_remove(pdev); return PTR_ERR(pdevs[i]); } } serdevs = kcalloc(dev_info->serdev_count, sizeof(*serdevs), GFP_KERNEL); if (!serdevs) { - x86_android_tablet_cleanup(); + x86_android_tablet_remove(pdev); return -ENOMEM; } @@ -335,7 +339,7 @@ static __init int x86_android_tablet_init(void) for (i = 0; i < serdev_count; i++) { ret = x86_instantiate_serdev(&dev_info->serdev_info[i], i); if (ret < 0) { - x86_android_tablet_cleanup(); + x86_android_tablet_remove(pdev); return ret; } } @@ -346,7 +350,7 @@ static __init int x86_android_tablet_init(void) buttons = kcalloc(dev_info->gpio_button_count, sizeof(*buttons), GFP_KERNEL); if (!buttons) { - x86_android_tablet_cleanup(); + x86_android_tablet_remove(pdev); return -ENOMEM; } @@ -354,7 +358,7 @@ static __init int x86_android_tablet_init(void) ret = x86_android_tablet_get_gpiod(dev_info->gpio_button[i].chip, dev_info->gpio_button[i].pin, &gpiod); if (ret < 0) { - x86_android_tablet_cleanup(); + x86_android_tablet_remove(pdev); return ret; } @@ -369,7 +373,7 @@ static __init int x86_android_tablet_init(void) PLATFORM_DEVID_AUTO, &pdata, sizeof(pdata)); if (IS_ERR(pdevs[pdev_count])) { - x86_android_tablet_cleanup(); + x86_android_tablet_remove(pdev); return PTR_ERR(pdevs[pdev_count]); } pdev_count++; @@ -378,8 +382,35 @@ static __init int x86_android_tablet_init(void) return 0; } +static struct platform_driver x86_android_tablet_driver = { + .driver = { + .name = KBUILD_MODNAME, + }, + .remove_new = x86_android_tablet_remove, +}; + +static int __init x86_android_tablet_init(void) +{ + if (!dmi_first_match(x86_android_tablet_ids)) { + pr_err("error loaded on unknown tablet model\n"); + return -ENODEV; + } + + x86_android_tablet_device = platform_create_bundle(&x86_android_tablet_driver, + x86_android_tablet_probe, + NULL, 0, NULL, 0); + + return PTR_ERR_OR_ZERO(x86_android_tablet_device); +} + +static void __exit x86_android_tablet_exit(void) +{ + platform_device_unregister(x86_android_tablet_device); + platform_driver_unregister(&x86_android_tablet_driver); +} + module_init(x86_android_tablet_init); -module_exit(x86_android_tablet_cleanup); +module_exit(x86_android_tablet_exit); MODULE_AUTHOR("Hans de Goede "); MODULE_DESCRIPTION("X86 Android tablets DSDT fixups driver"); From patchwork Sat Sep 9 14:18:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 721232 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92314EE3EC1 for ; Sat, 9 Sep 2023 16:27:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231349AbjIIQZS (ORCPT ); Sat, 9 Sep 2023 12:25:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346378AbjIIOUN (ORCPT ); Sat, 9 Sep 2023 10:20:13 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 905E9E45 for ; Sat, 9 Sep 2023 07:18:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694269114; 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: in-reply-to:in-reply-to:references:references; bh=WnWosMnrT6Tj83USTGbuArWvmKIv0wvZD8gCMTfOryA=; b=CDEIMUtrQFna33yC3G8nv0g1PoOKy6yp9fNfB05+poFkts8C/ISu2b3SL16BnaRH6/8SBA 1sLuOmW94Trv3SG6wCqlSwjgQTw6XZAEcliZJT/C5ndS0JItZBdE9oAjxEuDUdeO+zHmdw nEflb/E+7YErcw295b0c/UBcZV6bWYU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-277-UvLTnKirM7qqyzxeWCI1Ug-1; Sat, 09 Sep 2023 10:18:31 -0400 X-MC-Unique: UvLTnKirM7qqyzxeWCI1Ug-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 327848001EA; Sat, 9 Sep 2023 14:18:31 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 195F7142B960; Sat, 9 Sep 2023 14:18:29 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mika Westerberg , Andy Shevchenko , Bartosz Golaszewski , Linus Walleij Cc: Hans de Goede , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [PATCH 6/8] platform/x86: x86-android-tablets: Stop using gpiolib private APIs Date: Sat, 9 Sep 2023 16:18:14 +0200 Message-ID: <20230909141816.58358-7-hdegoede@redhat.com> In-Reply-To: <20230909141816.58358-1-hdegoede@redhat.com> References: <20230909141816.58358-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Refactor x86_android_tablet_get_gpiod() to no longer use gpiolib private functions like gpiochip_find(). As a bonus this allows specifying that the GPIO is active-low, like the /CE (charge enable) pin on the bq25892 charger on the Lenovo Yoga Tablet 3. Reported-by: Bartosz Golaszewski Closes: https://lore.kernel.org/platform-driver-x86/20230905185309.131295-12-brgl@bgdev.pl/ Signed-off-by: Hans de Goede Reviewed-by: Andy Shevchenko --- .../platform/x86/x86-android-tablets/asus.c | 1 + .../platform/x86/x86-android-tablets/core.c | 51 +++++++++++-------- .../platform/x86/x86-android-tablets/lenovo.c | 28 +++++----- .../platform/x86/x86-android-tablets/other.c | 6 +++ .../x86-android-tablets/x86-android-tablets.h | 6 ++- 5 files changed, 55 insertions(+), 37 deletions(-) diff --git a/drivers/platform/x86/x86-android-tablets/asus.c b/drivers/platform/x86/x86-android-tablets/asus.c index f9c4083be86d..227afbb51078 100644 --- a/drivers/platform/x86/x86-android-tablets/asus.c +++ b/drivers/platform/x86/x86-android-tablets/asus.c @@ -303,6 +303,7 @@ static const struct x86_i2c_client_info asus_tf103c_i2c_clients[] __initconst = .index = 28, .trigger = ACPI_EDGE_SENSITIVE, .polarity = ACPI_ACTIVE_LOW, + .con_id = "atmel_mxt_ts_irq", }, }, }; diff --git a/drivers/platform/x86/x86-android-tablets/core.c b/drivers/platform/x86/x86-android-tablets/core.c index 3d3101b2848f..673f3a14941b 100644 --- a/drivers/platform/x86/x86-android-tablets/core.c +++ b/drivers/platform/x86/x86-android-tablets/core.c @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include #include @@ -21,35 +21,39 @@ #include #include "x86-android-tablets.h" -/* For gpiochip_get_desc() which is EXPORT_SYMBOL_GPL() */ -#include "../../../gpio/gpiolib.h" -#include "../../../gpio/gpiolib-acpi.h" static struct platform_device *x86_android_tablet_device; -static int gpiochip_find_match_label(struct gpio_chip *gc, void *data) -{ - return gc->label && !strcmp(gc->label, data); -} - -int x86_android_tablet_get_gpiod(const char *label, int pin, struct gpio_desc **desc) +int x86_android_tablet_get_gpiod(const char *chip, int pin, const char *con_id, + bool active_low, enum gpiod_flags dflags, + struct gpio_desc **desc) { + struct gpiod_lookup_table *lookup; struct gpio_desc *gpiod; - struct gpio_chip *chip; - chip = gpiochip_find((void *)label, gpiochip_find_match_label); - if (!chip) { - pr_err("error cannot find GPIO chip %s\n", label); - return -ENODEV; - } + lookup = kzalloc(struct_size(lookup, table, 2), GFP_KERNEL); + if (!lookup) + return -ENOMEM; + + lookup->dev_id = KBUILD_MODNAME; + lookup->table[0].key = chip; + lookup->table[0].chip_hwnum = pin; + lookup->table[0].con_id = con_id; + lookup->table[0].flags = active_low ? GPIO_ACTIVE_LOW : GPIO_ACTIVE_HIGH; + + gpiod_add_lookup_table(lookup); + gpiod = devm_gpiod_get(&x86_android_tablet_device->dev, con_id, dflags); + gpiod_remove_lookup_table(lookup); + kfree(lookup); - gpiod = gpiochip_get_desc(chip, pin); if (IS_ERR(gpiod)) { - pr_err("error %ld getting GPIO %s %d\n", PTR_ERR(gpiod), label, pin); + pr_err("error %ld getting GPIO %s %d\n", PTR_ERR(gpiod), chip, pin); return PTR_ERR(gpiod); } - *desc = gpiod; + if (desc) + *desc = gpiod; + return 0; } @@ -79,7 +83,8 @@ int x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data) return irq; case X86_ACPI_IRQ_TYPE_GPIOINT: /* Like acpi_dev_gpio_irq_get(), but without parsing ACPI resources */ - ret = x86_android_tablet_get_gpiod(data->chip, data->index, &gpiod); + ret = x86_android_tablet_get_gpiod(data->chip, data->index, data->con_id, + false, GPIOD_ASIS, &gpiod); if (ret) return ret; @@ -356,7 +361,9 @@ static __init int x86_android_tablet_probe(struct platform_device *pdev) for (i = 0; i < dev_info->gpio_button_count; i++) { ret = x86_android_tablet_get_gpiod(dev_info->gpio_button[i].chip, - dev_info->gpio_button[i].pin, &gpiod); + dev_info->gpio_button[i].pin, + dev_info->gpio_button[i].button.desc, + false, GPIOD_IN, &gpiod); if (ret < 0) { x86_android_tablet_remove(pdev); return ret; @@ -364,6 +371,8 @@ static __init int x86_android_tablet_probe(struct platform_device *pdev) buttons[i] = dev_info->gpio_button[i].button; buttons[i].gpio = desc_to_gpio(gpiod); + /* Release gpiod so that gpio-keys can request it */ + devm_gpiod_put(&x86_android_tablet_device->dev, gpiod); } pdata.buttons = buttons; diff --git a/drivers/platform/x86/x86-android-tablets/lenovo.c b/drivers/platform/x86/x86-android-tablets/lenovo.c index 26a4ef670ad7..35aa2968d726 100644 --- a/drivers/platform/x86/x86-android-tablets/lenovo.c +++ b/drivers/platform/x86/x86-android-tablets/lenovo.c @@ -95,6 +95,7 @@ static const struct x86_i2c_client_info lenovo_yb1_x90_i2c_clients[] __initconst .index = 56, .trigger = ACPI_EDGE_SENSITIVE, .polarity = ACPI_ACTIVE_LOW, + .con_id = "goodix_ts_irq", }, }, { /* Wacom Digitizer in keyboard half */ @@ -111,6 +112,7 @@ static const struct x86_i2c_client_info lenovo_yb1_x90_i2c_clients[] __initconst .index = 49, .trigger = ACPI_LEVEL_SENSITIVE, .polarity = ACPI_ACTIVE_LOW, + .con_id = "wacom_irq", }, }, { /* LP8557 Backlight controller */ @@ -136,6 +138,7 @@ static const struct x86_i2c_client_info lenovo_yb1_x90_i2c_clients[] __initconst .index = 77, .trigger = ACPI_LEVEL_SENSITIVE, .polarity = ACPI_ACTIVE_LOW, + .con_id = "hideep_ts_irq", }, }, }; @@ -321,6 +324,7 @@ static struct x86_i2c_client_info lenovo_yoga_tab2_830_1050_i2c_clients[] __init .index = 2, .trigger = ACPI_EDGE_SENSITIVE, .polarity = ACPI_ACTIVE_HIGH, + .con_id = "bq24292i_irq", }, }, { /* BQ27541 fuel-gauge */ @@ -431,7 +435,8 @@ static int __init lenovo_yoga_tab2_830_1050_init_touchscreen(void) int ret; /* Use PMIC GPIO 10 bootstrap pin to differentiate 830 vs 1050 */ - ret = x86_android_tablet_get_gpiod("gpio_crystalcove", 10, &gpiod); + ret = x86_android_tablet_get_gpiod("gpio_crystalcove", 10, "yoga_bootstrap", + false, GPIOD_IN, &gpiod); if (ret) return ret; @@ -615,6 +620,7 @@ static const struct x86_i2c_client_info lenovo_yt3_i2c_clients[] __initconst = { .index = 5, .trigger = ACPI_EDGE_SENSITIVE, .polarity = ACPI_ACTIVE_LOW, + .con_id = "bq25892_0_irq", }, }, { /* bq27500 fuel-gauge for the round li-ion cells in the hinge */ @@ -640,6 +646,7 @@ static const struct x86_i2c_client_info lenovo_yt3_i2c_clients[] __initconst = { .index = 77, .trigger = ACPI_LEVEL_SENSITIVE, .polarity = ACPI_ACTIVE_LOW, + .con_id = "hideep_ts_irq", }, }, { /* LP8557 Backlight controller */ @@ -655,7 +662,6 @@ static const struct x86_i2c_client_info lenovo_yt3_i2c_clients[] __initconst = { static int __init lenovo_yt3_init(void) { - struct gpio_desc *gpiod; int ret; /* @@ -665,31 +671,23 @@ static int __init lenovo_yt3_init(void) * * The bq25890_charger driver controls these through I2C, but this only * works if not overridden by the pins. Set these pins here: - * 1. Set /CE to 0 to allow charging. + * 1. Set /CE to 1 to allow charging. * 2. Set OTG to 0 disable V5 boost output since the 5V boost output of * the main "bq25892_1" charger is used when necessary. */ /* /CE pin */ - ret = x86_android_tablet_get_gpiod("INT33FF:02", 22, &gpiod); + ret = x86_android_tablet_get_gpiod("INT33FF:02", 22, "bq25892_0_ce", + true, GPIOD_OUT_HIGH, NULL); if (ret < 0) return ret; - /* - * The gpio_desc returned by x86_android_tablet_get_gpiod() is a "raw" - * gpio_desc, that is there is no way to pass lookup-flags like - * GPIO_ACTIVE_LOW. Set the GPIO to 0 here to enable charging since - * the /CE pin is active-low, but not marked as such in the gpio_desc. - */ - gpiod_set_value(gpiod, 0); - /* OTG pin */ - ret = x86_android_tablet_get_gpiod("INT33FF:03", 19, &gpiod); + ret = x86_android_tablet_get_gpiod("INT33FF:03", 19, "bq25892_0_otg", + false, GPIOD_OUT_LOW, NULL); if (ret < 0) return ret; - gpiod_set_value(gpiod, 0); - /* Enable the regulators used by the touchscreen */ intel_soc_pmic_exec_mipi_pmic_seq_element(0x6e, 0x9b, 0x02, 0xff); intel_soc_pmic_exec_mipi_pmic_seq_element(0x6e, 0xa0, 0x02, 0xff); diff --git a/drivers/platform/x86/x86-android-tablets/other.c b/drivers/platform/x86/x86-android-tablets/other.c index 621ca1e54d1f..bc6bbf7ec6ea 100644 --- a/drivers/platform/x86/x86-android-tablets/other.c +++ b/drivers/platform/x86/x86-android-tablets/other.c @@ -47,6 +47,7 @@ static const struct x86_i2c_client_info acer_b1_750_i2c_clients[] __initconst = .index = 3, .trigger = ACPI_EDGE_SENSITIVE, .polarity = ACPI_ACTIVE_LOW, + .con_id = "NVT-ts_irq", }, }, { /* BMA250E accelerometer */ @@ -62,6 +63,7 @@ static const struct x86_i2c_client_info acer_b1_750_i2c_clients[] __initconst = .index = 25, .trigger = ACPI_LEVEL_SENSITIVE, .polarity = ACPI_ACTIVE_HIGH, + .con_id = "bma250e_irq", }, }, }; @@ -174,6 +176,7 @@ static const struct x86_i2c_client_info chuwi_hi8_i2c_clients[] __initconst = { .index = 23, .trigger = ACPI_LEVEL_SENSITIVE, .polarity = ACPI_ACTIVE_HIGH, + .con_id = "bma250e_irq", }, }, }; @@ -312,6 +315,7 @@ static const struct x86_i2c_client_info medion_lifetab_s10346_i2c_clients[] __in .index = 23, .trigger = ACPI_EDGE_SENSITIVE, .polarity = ACPI_ACTIVE_HIGH, + .con_id = "kxtj21009_irq", }, }, { /* goodix touchscreen */ @@ -402,6 +406,7 @@ static const struct x86_i2c_client_info nextbook_ares8_i2c_clients[] __initconst .index = 3, .trigger = ACPI_EDGE_SENSITIVE, .polarity = ACPI_ACTIVE_LOW, + .con_id = "ft5416_irq", }, }, }; @@ -460,6 +465,7 @@ static const struct x86_i2c_client_info nextbook_ares8a_i2c_clients[] __initcons .index = 17, .trigger = ACPI_EDGE_SENSITIVE, .polarity = ACPI_ACTIVE_LOW, + .con_id = "ft5416_irq", }, }, }; diff --git a/drivers/platform/x86/x86-android-tablets/x86-android-tablets.h b/drivers/platform/x86/x86-android-tablets/x86-android-tablets.h index bf97fb84c0d4..9d2fb7fded6d 100644 --- a/drivers/platform/x86/x86-android-tablets/x86-android-tablets.h +++ b/drivers/platform/x86/x86-android-tablets/x86-android-tablets.h @@ -10,6 +10,7 @@ #ifndef __PDX86_X86_ANDROID_TABLETS_H #define __PDX86_X86_ANDROID_TABLETS_H +#include #include #include #include @@ -37,6 +38,7 @@ struct x86_acpi_irq_data { int index; int trigger; /* ACPI_EDGE_SENSITIVE / ACPI_LEVEL_SENSITIVE */ int polarity; /* ACPI_ACTIVE_HIGH / ACPI_ACTIVE_LOW / ACPI_ACTIVE_BOTH */ + const char *con_id; }; /* Structs to describe devices to instantiate */ @@ -81,7 +83,9 @@ struct x86_dev_info { void (*exit)(void); }; -int x86_android_tablet_get_gpiod(const char *label, int pin, struct gpio_desc **desc); +int x86_android_tablet_get_gpiod(const char *chip, int pin, const char *con_id, + bool active_low, enum gpiod_flags dflags, + struct gpio_desc **desc); int x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data); /* From patchwork Sat Sep 9 14:18:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 721124 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12D9CEEB59A for ; Sat, 9 Sep 2023 16:25:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231810AbjIIQZU (ORCPT ); Sat, 9 Sep 2023 12:25:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346379AbjIIOUN (ORCPT ); Sat, 9 Sep 2023 10:20:13 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50E63E44 for ; Sat, 9 Sep 2023 07:18:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694269114; 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: in-reply-to:in-reply-to:references:references; bh=CdsDqz0zPOy7jhgwrTpUp+gZgwT9fxcigX67K+/zeIs=; b=DTDxvr2Tas5fzdnNVgAeOSXMtRr+JU1TkrVxqwuEMTDmBYV2vQxENwRWG2q9MtgoJdlkUB WTWcOVnKfwTgkgYuTxQTOyr5mp8V4DOtxStMIWgVYGtDvzVgNxAUW6jRC42uzxiQ9gz8yy c7hPL+4b0FvvTITeahEDAWh0hVCGTUo= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-655-R4Sy07_2OC6hoH4Ca72KFQ-1; Sat, 09 Sep 2023 10:18:33 -0400 X-MC-Unique: R4Sy07_2OC6hoH4Ca72KFQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7C1F2380671E; Sat, 9 Sep 2023 14:18:32 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 632A614171B6; Sat, 9 Sep 2023 14:18:31 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mika Westerberg , Andy Shevchenko , Bartosz Golaszewski , Linus Walleij Cc: Hans de Goede , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [PATCH 7/8] platform/x86: x86-android-tablets: Use platform-device as gpio-keys parent Date: Sat, 9 Sep 2023 16:18:15 +0200 Message-ID: <20230909141816.58358-8-hdegoede@redhat.com> In-Reply-To: <20230909141816.58358-1-hdegoede@redhat.com> References: <20230909141816.58358-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Use the new x86-android-tablets platform-device as gpio-keys parent to make it clear that this gpio-keys device was instantiated by the x86-android-tablets driver. Signed-off-by: Hans de Goede --- drivers/platform/x86/x86-android-tablets/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/x86/x86-android-tablets/core.c b/drivers/platform/x86/x86-android-tablets/core.c index 673f3a14941b..b72bb0376fe5 100644 --- a/drivers/platform/x86/x86-android-tablets/core.c +++ b/drivers/platform/x86/x86-android-tablets/core.c @@ -378,7 +378,7 @@ static __init int x86_android_tablet_probe(struct platform_device *pdev) pdata.buttons = buttons; pdata.nbuttons = dev_info->gpio_button_count; - pdevs[pdev_count] = platform_device_register_data(NULL, "gpio-keys", + pdevs[pdev_count] = platform_device_register_data(&pdev->dev, "gpio-keys", PLATFORM_DEVID_AUTO, &pdata, sizeof(pdata)); if (IS_ERR(pdevs[pdev_count])) { From patchwork Sat Sep 9 14:18:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 721235 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8AFDEEB598 for ; Sat, 9 Sep 2023 16:25:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231610AbjIIQZT (ORCPT ); Sat, 9 Sep 2023 12:25:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346376AbjIIOUN (ORCPT ); Sat, 9 Sep 2023 10:20:13 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E1A8CCA for ; Sat, 9 Sep 2023 07:18:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694269119; 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: in-reply-to:in-reply-to:references:references; bh=V9w02tjgg+rCW2IRt1y+039+nKLy7RT6uNR25PwjTMs=; b=I8/zP6LUtAMczXLfBV+sjgKEjCXkgzregJMbxD3eB65JAVnGG+Qc/LD73orI/hqSK1cN1o dtUcI+TiwqvGcG+p/LlEP+9p1fOEPyjWrobtjdPjmIl31nl3COS2pOVm5U6TEPQ/f8zZhH MkQY1LKb33+HngvqiCExqYgRyEBp/8Q= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-138-diEMnHx0OOSxA39h2iSYQw-1; Sat, 09 Sep 2023 10:18:34 -0400 X-MC-Unique: diEMnHx0OOSxA39h2iSYQw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C4D9A3803909; Sat, 9 Sep 2023 14:18:33 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD4441460FE5; Sat, 9 Sep 2023 14:18:32 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Mika Westerberg , Andy Shevchenko , Bartosz Golaszewski , Linus Walleij Cc: Hans de Goede , platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [PATCH 8/8] platform/x86: x86-android-tablets: Drop "linux,power-supply-name" from lenovo_yt3_bq25892_0_props[] Date: Sat, 9 Sep 2023 16:18:16 +0200 Message-ID: <20230909141816.58358-9-hdegoede@redhat.com> In-Reply-To: <20230909141816.58358-1-hdegoede@redhat.com> References: <20230909141816.58358-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The "linux,power-supply-name" property is a left-over from an earlier attempt to allow properties to specify the power_supply class-device name. The patch to read this property never made it upstream (and is no longer necessary). Drop the unused property. Signed-off-by: Hans de Goede --- drivers/platform/x86/x86-android-tablets/lenovo.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/platform/x86/x86-android-tablets/lenovo.c b/drivers/platform/x86/x86-android-tablets/lenovo.c index 35aa2968d726..5c803cdb5586 100644 --- a/drivers/platform/x86/x86-android-tablets/lenovo.c +++ b/drivers/platform/x86/x86-android-tablets/lenovo.c @@ -565,7 +565,6 @@ static const struct software_node fg_bq25890_1_supply_node = { /* bq25892 charger settings for the flat lipo battery behind the screen */ static const struct property_entry lenovo_yt3_bq25892_0_props[] = { PROPERTY_ENTRY_STRING_ARRAY("supplied-from", lenovo_yt3_bq25892_0_suppliers), - PROPERTY_ENTRY_STRING("linux,power-supply-name", "bq25892-second-chrg"), PROPERTY_ENTRY_U32("linux,iinlim-percentage", 40), PROPERTY_ENTRY_BOOL("linux,skip-reset"), /* Values taken from Android Factory Image */