Linux USB
 help / color / mirror / Atom feed
* [PATCH v2] platform/x86: serial-multi-instantiate: allow single GpioInt IRQ for INT3515
@ 2023-12-12  0:46 Michał Kopeć
  2023-12-12 10:38 ` [PATCH] " Michał Kopeć
  0 siblings, 1 reply; 7+ messages in thread
From: Michał Kopeć @ 2023-12-12  0:46 UTC (permalink / raw)
  To: linux-usb; +Cc: Hans de Goede

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ć <michal@nozomi.space>
---
 .../platform/x86/serial-multi-instantiate.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

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");
    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,
-- 
2.43.0






^ permalink raw reply related	[flat|nested] 7+ messages in thread
* [PATCH] platform/x86: serial-multi-instantiate: allow single GpioInt IRQ for INT3515
@ 2023-12-12  0:39 Michał Kopeć
  2023-12-14  9:58 ` Hans de Goede
  0 siblings, 1 reply; 7+ messages in thread
From: Michał Kopeć @ 2023-12-12  0:39 UTC (permalink / raw)
  To: linux-usb; +Cc: hdegoede

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.

Signed-off-by: Michał Kopeć <michal@nozomi.space>
---
 .../platform/x86/serial-multi-instantiate.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

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");
    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,
-- 
2.43.0






^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-01-03 11:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-12  0:46 [PATCH v2] platform/x86: serial-multi-instantiate: allow single GpioInt IRQ for INT3515 Michał Kopeć
2023-12-12 10:38 ` [PATCH] " Michał Kopeć
2023-12-12 22:37   ` kernel test robot
2023-12-18  0:54   ` kernel test robot
2024-01-03 11:17   ` Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2023-12-12  0:39 Michał Kopeć
2023-12-14  9:58 ` Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox