From patchwork Tue Dec 12 00:46:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBLb3BlxIc=?= X-Patchwork-Id: 13488253 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=nozomi.space header.i=@nozomi.space header.b="rgXsXynP" Received: from mail.nozomi.space (mail.nozomi.space [139.162.184.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40A1499 for ; Mon, 11 Dec 2023 16:46:33 -0800 (PST) Date: Tue, 12 Dec 2023 01:46:24 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nozomi.space; s=mail; t=1702341990; bh=cjkge3z+KaAw64Tp+7lotjeEnGyo9RIxiijjuRhseEo=; h=From:Subject:To:Cc; b=rgXsXynPcumIjg2yOLBCFHpBVh/9ZMpNW+UzmEf/h8Rvl6gwKIMemaXbOnYEAPTER qbgu++PKGVIKu1Jd1kWt51GLsl51vrBIyBxLgStcgkfMiExbzA1lf2lCRwK3UcIqvP JuNS4f5l/5BWn9J2zzCBt7L8QYoxbw477/zQnfousyH2uVHDUsAJq8o+sRouCnZuHV LcxqTotaHmez2NCXeFpouhQqV6kxY8o0z+5DLalLcZIlUWTe8WbvMUE3ChZfqE15Xo wNWAULcaXF4bBxCjGqmiGFQrsMu7O1js6MQIHqXeA2tb0P/lOqKWymJ9Vt5MvQdEeh zmy8NWFrmtLErU9gPci+M0OvNPZDDvYBgmCcpKSVs3M2eLUP/HoTd7G/97sK6f1wr0 luiwQd0/VXYt5Ewyi6z3jzWXY/kLx+fGIE8edJjr8ykdU3Mx1ZVKKJtHQ9DKSLQUpv ZIO8ml7Gu5Vtl/XP8/Q2Ka2rwvx7NcpDnhUrIIorRyyUjY2kp7f7h3l5Q0dU6cS+iu tKLSQOfgW8bUYbj1oHapll3YyP0ed7X90nE9kpVvWT8iE3uZJGU37Ev9wgrHY3Z7yr xSh9qw19CA+u7Ld4QWYIyLaNH1JXLUTCUjr9WZgqJYJthuxshEIE1cnl3AN/2ud7QY n5k5+0GSNLaufENCKmvfpUAU= From: =?iso-8859-2?q?Micha=B3_Kope=E6?= Subject: [PATCH v2] platform/x86: serial-multi-instantiate: allow single GpioInt IRQ for INT3515 To: linux-usb Cc: Hans de Goede Message-Id: Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On some devices, such as the Lenovo ThinkPad T14 Gen1 (AMD), there is only one GpioInt resource defined for all i2c device instances. Handle this case appropriately by autodetecting the irq type and allowing fallback to the first IRQ index for the second, third and fourth tps6598x instances. Additionally, to use the `platform_get_irq_optional` function to silence errors that may not be relevant if the IRQ is optional. In cases where the IRQ is not optional, `dev_err_probe` is still triggered, so other devices will not be affected by this change. v2: fix linewrap in summary Signed-off-by: Michał Kopeć --- .../platform/x86/serial-multi-instantiate.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) break; @@ -69,12 +71,12 @@ static int smi_get_irq(struct platform_device *pdev, struct acpi_device *adev, ret = acpi_dev_gpio_irq_get(adev, inst->irq_idx); break; case IRQ_RESOURCE_APIC: - ret = platform_get_irq(pdev, inst->irq_idx); + ret = platform_get_irq_optional(pdev, inst->irq_idx); break; default: return 0; } - if (ret < 0) + if (ret < 0 && !inst->flags & IRQ_OPTIONAL) return dev_err_probe(&pdev->dev, ret, "Error requesting irq at index %d\n", inst->irq_idx); @@ -210,6 +212,8 @@ static int smi_i2c_probe(struct platform_device *pdev, struct smi *smi, board_info.dev_name = name; ret = smi_get_irq(pdev, adev, &inst_array[i]); + if (ret < 0 && inst_array[i].flags & IRQ_OPTIONAL) + ret = smi_get_irq(pdev, adev, &inst_array[0]); if (ret < 0) goto error; board_info.irq = ret; @@ -309,10 +313,11 @@ static const struct smi_node bsg2150_data = { static const struct smi_node int3515_data = { .instances = { - { "tps6598x", IRQ_RESOURCE_APIC, 0 }, - { "tps6598x", IRQ_RESOURCE_APIC, 1 }, - { "tps6598x", IRQ_RESOURCE_APIC, 2 }, - { "tps6598x", IRQ_RESOURCE_APIC, 3 }, + { "tps6598x", IRQ_RESOURCE_AUTO, 0 }, + /* On some platforms only one shared GpioInt is defined */ + { "tps6598x", IRQ_RESOURCE_AUTO | IRQ_OPTIONAL, 1 }, + { "tps6598x", IRQ_RESOURCE_AUTO | IRQ_OPTIONAL, 2 }, + { "tps6598x", IRQ_RESOURCE_AUTO | IRQ_OPTIONAL, 3 }, {} }, .bus_type = SMI_I2C, diff --git a/drivers/platform/x86/serial-multi-instantiate.c b/drivers/platform/x86/serial-multi-instantiate.c index 8158e3cf5d6d..1c4cc44d5a88 100644 --- a/drivers/platform/x86/serial-multi-instantiate.c +++ b/drivers/platform/x86/serial-multi-instantiate.c @@ -23,6 +23,8 @@ #define IRQ_RESOURCE_APIC 2 #define IRQ_RESOURCE_AUTO 3 +#define IRQ_OPTIONAL BIT(2) + enum smi_bus_type { SMI_I2C, SMI_SPI, @@ -59,7 +61,7 @@ static int smi_get_irq(struct platform_device *pdev, struct acpi_device *adev, dev_dbg(&pdev->dev, "Using gpio irq\n"); break; } - ret = platform_get_irq(pdev, inst->irq_idx); + ret = platform_get_irq_optional(pdev, inst->irq_idx); if (ret > 0) { dev_dbg(&pdev->dev, "Using platform irq\n");