]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
i3c: mipi-i3c-hci-pci: Assign unique device names and IDs for Intel LPSS I3C
authorAdrian Hunter <adrian.hunter@intel.com>
Tue, 6 Jan 2026 16:44:11 +0000 (18:44 +0200)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Wed, 14 Jan 2026 14:53:33 +0000 (15:53 +0100)
Simplify the code and ensure names and IDs align with device documentation.
Use explicit device names and IDs for Intel LPSS I3C controllers instead of
dynamically allocated values.

Add "intel-lpss-i3c" to the platform_device_id table in the mipi-i3c-hci
driver and use the same name for Intel I3C controllers in the
mipi_i3c_hci_pci driver.  Assign hard-coded IDs to reflect the hardware
layout.

Intel SoCs include two I3C PCI devices in the Low Power Subsystem (LPSS),
each supporting up to two I3C buses. The second PCI device is assigned ID 2
(not 1) to match this topology.  Additional IDs will be introduced when
Multi-Bus Instance support is implemented.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20260106164416.67074-7-adrian.hunter@intel.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/i3c/master/mipi-i3c-hci/core.c
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c

index 07fb91a1259377b839103dc5fa41a31ac014f5e0..3d6544a64188716d68e8d88032d10f5ac0448a38 100644 (file)
@@ -790,9 +790,16 @@ static const struct acpi_device_id i3c_hci_acpi_match[] = {
 };
 MODULE_DEVICE_TABLE(acpi, i3c_hci_acpi_match);
 
+static const struct platform_device_id i3c_hci_driver_ids[] = {
+       { .name = "intel-lpss-i3c" },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(platform, i3c_hci_driver_ids);
+
 static struct platform_driver i3c_hci_driver = {
        .probe = i3c_hci_probe,
        .remove = i3c_hci_remove,
+       .id_table = i3c_hci_driver_ids,
        .driver = {
                .name = "mipi-i3c-hci",
                .of_match_table = of_match_ptr(i3c_hci_of_match),
index 0fd3587671e13320959e8e46fb8af797a5733cb9..3b319fbf18ce3fb3b2feaeff1f0cdcf19f4864f8 100644 (file)
@@ -27,10 +27,10 @@ struct mipi_i3c_hci_pci {
 struct mipi_i3c_hci_pci_info {
        int (*init)(struct mipi_i3c_hci_pci *hci);
        void (*exit)(struct mipi_i3c_hci_pci *hci);
+       const char *name;
+       int id;
 };
 
-static DEFINE_IDA(mipi_i3c_hci_pci_ida);
-
 #define INTEL_PRIV_OFFSET              0x2b0
 #define INTEL_PRIV_SIZE                        0x28
 #define INTEL_RESETS                   0x04
@@ -179,9 +179,18 @@ static void intel_i3c_exit(struct mipi_i3c_hci_pci *hci)
        intel_ltr_hide(&hci->pci->dev);
 }
 
-static const struct mipi_i3c_hci_pci_info intel_info = {
+static const struct mipi_i3c_hci_pci_info intel_1_info = {
        .init = intel_i3c_init,
        .exit = intel_i3c_exit,
+       .name = "intel-lpss-i3c",
+       .id = 0,
+};
+
+static const struct mipi_i3c_hci_pci_info intel_2_info = {
+       .init = intel_i3c_init,
+       .exit = intel_i3c_exit,
+       .name = "intel-lpss-i3c",
+       .id = 2,
 };
 
 static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
@@ -189,7 +198,7 @@ static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
 {
        struct mipi_i3c_hci_pci *hci;
        struct resource res[2];
-       int dev_id, ret;
+       int ret;
 
        hci = devm_kzalloc(&pci->dev, sizeof(*hci), GFP_KERNEL);
        if (!hci)
@@ -217,11 +226,9 @@ static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
        res[1].start = pci_irq_vector(hci->pci, 0);
        res[1].end = res[1].start;
 
-       dev_id = ida_alloc(&mipi_i3c_hci_pci_ida, GFP_KERNEL);
-       if (dev_id < 0)
-               return dev_id;
+       hci->info = (const struct mipi_i3c_hci_pci_info *)id->driver_data;
 
-       hci->pdev = platform_device_alloc("mipi-i3c-hci", dev_id);
+       hci->pdev = platform_device_alloc(hci->info->name, hci->info->id);
        if (!hci->pdev)
                return -ENOMEM;
 
@@ -232,7 +239,6 @@ static int mipi_i3c_hci_pci_probe(struct pci_dev *pci,
        if (ret)
                goto err;
 
-       hci->info = (const struct mipi_i3c_hci_pci_info *)id->driver_data;
        if (hci->info->init) {
                ret = hci->info->init(hci);
                if (ret)
@@ -252,7 +258,6 @@ err_exit:
                hci->info->exit(hci);
 err:
        platform_device_put(hci->pdev);
-       ida_free(&mipi_i3c_hci_pci_ida, dev_id);
        return ret;
 }
 
@@ -260,28 +265,26 @@ static void mipi_i3c_hci_pci_remove(struct pci_dev *pci)
 {
        struct mipi_i3c_hci_pci *hci = pci_get_drvdata(pci);
        struct platform_device *pdev = hci->pdev;
-       int dev_id = pdev->id;
 
        if (hci->info->exit)
                hci->info->exit(hci);
 
        platform_device_unregister(pdev);
-       ida_free(&mipi_i3c_hci_pci_ida, dev_id);
 }
 
 static const struct pci_device_id mipi_i3c_hci_pci_devices[] = {
        /* Wildcat Lake-U */
-       { PCI_VDEVICE(INTEL, 0x4d7c), (kernel_ulong_t)&intel_info},
-       { PCI_VDEVICE(INTEL, 0x4d6f), (kernel_ulong_t)&intel_info},
+       { PCI_VDEVICE(INTEL, 0x4d7c), (kernel_ulong_t)&intel_1_info},
+       { PCI_VDEVICE(INTEL, 0x4d6f), (kernel_ulong_t)&intel_2_info},
        /* Panther Lake-H */
-       { PCI_VDEVICE(INTEL, 0xe37c), (kernel_ulong_t)&intel_info},
-       { PCI_VDEVICE(INTEL, 0xe36f), (kernel_ulong_t)&intel_info},
+       { PCI_VDEVICE(INTEL, 0xe37c), (kernel_ulong_t)&intel_1_info},
+       { PCI_VDEVICE(INTEL, 0xe36f), (kernel_ulong_t)&intel_2_info},
        /* Panther Lake-P */
-       { PCI_VDEVICE(INTEL, 0xe47c), (kernel_ulong_t)&intel_info},
-       { PCI_VDEVICE(INTEL, 0xe46f), (kernel_ulong_t)&intel_info},
+       { PCI_VDEVICE(INTEL, 0xe47c), (kernel_ulong_t)&intel_1_info},
+       { PCI_VDEVICE(INTEL, 0xe46f), (kernel_ulong_t)&intel_2_info},
        /* Nova Lake-S */
-       { PCI_VDEVICE(INTEL, 0x6e2c), (kernel_ulong_t)&intel_info},
-       { PCI_VDEVICE(INTEL, 0x6e2d), (kernel_ulong_t)&intel_info},
+       { PCI_VDEVICE(INTEL, 0x6e2c), (kernel_ulong_t)&intel_1_info},
+       { PCI_VDEVICE(INTEL, 0x6e2d), (kernel_ulong_t)&intel_2_info},
        { },
 };
 MODULE_DEVICE_TABLE(pci, mipi_i3c_hci_pci_devices);