From patchwork Mon Jun 12 14:16:31 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: 13276771 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 2E8B6C88CB8 for ; Mon, 12 Jun 2023 14:30:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237578AbjFLOap (ORCPT ); Mon, 12 Jun 2023 10:30:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239934AbjFLOZj (ORCPT ); Mon, 12 Jun 2023 10:25:39 -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 D3DAE1FDC for ; Mon, 12 Jun 2023 07:23:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686579762; 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=Pz2kuqiSFQSWJR9941DFWUWhLPb+zdyjk+fsL6/Qprg=; b=KaivCBY6ZYWbPrBgYmW4gj62yOXiJO5IIq1EZHuChwcaLhx7qh6jLRxEAJVP23yQuyqjtm J+80EOQ++jwcPCzJze6HPC4U7p5KZRetohF7Pv38iFp8wy5pjPsB8eFJR9q1wj81Lfr5wh RMY9EAiiLXIKsZBP1xIZ3bXzoY4RXYM= 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-133-7gjyhIGQMZKq2qLnX_JtIA-1; Mon, 12 Jun 2023 10:16:34 -0400 X-MC-Unique: 7gjyhIGQMZKq2qLnX_JtIA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 54EE4101A53B; Mon, 12 Jun 2023 14:16:34 +0000 (UTC) Received: from x1.localdomain.com (unknown [10.39.195.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 606D740C20F4; Mon, 12 Jun 2023 14:16:33 +0000 (UTC) From: Hans de Goede To: Andy Shevchenko , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Dan Scally Cc: Hans de Goede , platform-driver-x86@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH 1/2] platform/x86: int3472: discrete: Fix getting active_value Date: Mon, 12 Jun 2023 16:16:31 +0200 Message-Id: <20230612141632.5232-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org acpi_object.integer.value is 64 bit, so to get bits 31-24 the value not only needs to be shifted but also masked. Signed-off-by: Hans de Goede --- drivers/platform/x86/intel/int3472/discrete.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c index fc839a73e411..4ef60883154d 100644 --- a/drivers/platform/x86/intel/int3472/discrete.c +++ b/drivers/platform/x86/intel/int3472/discrete.c @@ -179,7 +179,7 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares, int3472_get_func_and_polarity(type, &func, &polarity); /* If bits 31-24 of the _DSM entry are all 0 then the signal is inverted */ - active_value = obj->integer.value >> 24; + active_value = (obj->integer.value >> 24) & 0xff; if (!active_value) polarity ^= GPIO_ACTIVE_LOW; From patchwork Mon Jun 12 14:16:32 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: 13276770 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 14B34C88CB9 for ; Mon, 12 Jun 2023 14:26:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238708AbjFLO0j (ORCPT ); Mon, 12 Jun 2023 10:26:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238748AbjFLO0C (ORCPT ); Mon, 12 Jun 2023 10:26:02 -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 7ACFE3C21 for ; Mon, 12 Jun 2023 07:23:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686579781; 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=q4TwCgusytKSulbypQtYUJ/IonR429FcZB5BLgIBpv8=; b=LoJTvxaMS//7zCfrxcrxFtD1gyb8GO5FV3l4w3dG6Sp7gC0AhGl+WkRGVP6Qxumf4O/FXN FHCh0Hv3EGVnDY27u0GVRQ7Lm7fTnU32wtZAgxM0TDoInwFeA6ssdmunRrVThn+uKsKI7N 6K7gmNWlAMyXHl5XC+YP848gEzW7SZQ= Received: from mimecast-mx02.redhat.com (mx3-rdu2.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-478-1yqKf_YGNLyl0spoI3Noew-1; Mon, 12 Jun 2023 10:16:35 -0400 X-MC-Unique: 1yqKf_YGNLyl0spoI3Noew-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 69D073C11CCA; Mon, 12 Jun 2023 14:16:35 +0000 (UTC) Received: from x1.localdomain.com (unknown [10.39.195.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 869CF40C20F4; Mon, 12 Jun 2023 14:16:34 +0000 (UTC) From: Hans de Goede To: Andy Shevchenko , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Dan Scally Cc: Hans de Goede , platform-driver-x86@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH 2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match Date: Mon, 12 Jun 2023 16:16:32 +0200 Message-Id: <20230612141632.5232-2-hdegoede@redhat.com> In-Reply-To: <20230612141632.5232-1-hdegoede@redhat.com> References: <20230612141632.5232-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org The INT3472 discrete code assumes that the ACPI GPIO resources are in the same order as the pin-info _DSM entries. The returned pin-info includes the pin-number in bits 15-8. Add a check that this matches with the ACPI GPIO resource pin-number in case the assumption is not true with some ACPI tables. Signed-off-by: Hans de Goede --- drivers/platform/x86/intel/int3472/discrete.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c index 4ef60883154d..c1132bbbff41 100644 --- a/drivers/platform/x86/intel/int3472/discrete.c +++ b/drivers/platform/x86/intel/int3472/discrete.c @@ -149,8 +149,8 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares, { struct int3472_discrete_device *int3472 = data; struct acpi_resource_gpio *agpio; + u8 active_value, pin, type; union acpi_object *obj; - u8 active_value, type; const char *err_msg; const char *func; u32 polarity; @@ -174,10 +174,18 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares, return 1; } + /* Bits 7-0 contain the type/function of the pin */ type = obj->integer.value & 0xff; int3472_get_func_and_polarity(type, &func, &polarity); + /* Bits 15-8 contain the pin-number on the GPIO chip */ + pin = (obj->integer.value >> 8) & 0xff; + if (pin != agpio->pin_table[0]) + dev_warn(int3472->dev, "%s %s pin number mismatch _DSM %d resource %d\n", + func, agpio->resource_source.string_ptr, pin, + agpio->pin_table[0]); + /* If bits 31-24 of the _DSM entry are all 0 then the signal is inverted */ active_value = (obj->integer.value >> 24) & 0xff; if (!active_value)