]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mfd: intel_soc_pmic_bxtwc: Use IRQ domain for USB Type-C device
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Sat, 5 Oct 2024 19:27:04 +0000 (22:27 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 14 Dec 2024 18:51:00 +0000 (19:51 +0100)
[ Upstream commit 686fb77712a4bc94b76a0c5ae74c60118b7a0d79 ]

While design wise the idea of converting the driver to use
the hierarchy of the IRQ chips is correct, the implementation
has (inherited) flaws. This was unveiled when platform_get_irq()
had started WARN() on IRQ 0 that is supposed to be a Linux
IRQ number (also known as vIRQ).

Rework the driver to respect IRQ domain when creating each MFD
device separately, as the domain is not the same for all of them.

Fixes: 9c6235c86332 ("mfd: intel_soc_pmic_bxtwc: Add bxt_wcove_usbc device")
Fixes: d2061f9cc32d ("usb: typec: add driver for Intel Whiskey Cove PMIC USB Type-C PHY")
Fixes: 57129044f504 ("mfd: intel_soc_pmic_bxtwc: Use chained IRQs for second level IRQ chips")
Reported-by: Zhang Ning <zhangn1985@outlook.com>
Closes: https://lore.kernel.org/r/TY2PR01MB3322FEDCDC048B7D3794F922CDBA2@TY2PR01MB3322.jpnprd01.prod.outlook.com
Tested-by: Zhang Ning <zhangn1985@outlook.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20241005193029.1929139-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Lee Jones <lee@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mfd/intel_soc_pmic_bxtwc.c
drivers/usb/typec/tcpm/wcove.c

index 8e699844f23ba3d734511a19af3502b572ad5214..d2c13ef4bf33f9c40dc245742f0068a092ad2b38 100644 (file)
@@ -240,16 +240,6 @@ static struct mfd_cell bxt_wc_dev[] = {
                .num_resources = ARRAY_SIZE(thermal_resources),
                .resources = thermal_resources,
        },
-       {
-               .name = "bxt_wcove_usbc",
-               .num_resources = ARRAY_SIZE(usbc_resources),
-               .resources = usbc_resources,
-       },
-       {
-               .name = "bxt_wcove_ext_charger",
-               .num_resources = ARRAY_SIZE(charger_resources),
-               .resources = charger_resources,
-       },
        {
                .name = "bxt_wcove_bcu",
                .num_resources = ARRAY_SIZE(bcu_resources),
@@ -271,6 +261,19 @@ static struct mfd_cell bxt_wc_dev[] = {
        },
 };
 
+static struct mfd_cell bxt_wc_chgr_dev[] = {
+       {
+               .name = "bxt_wcove_usbc",
+               .num_resources = ARRAY_SIZE(usbc_resources),
+               .resources = usbc_resources,
+       },
+       {
+               .name = "bxt_wcove_ext_charger",
+               .num_resources = ARRAY_SIZE(charger_resources),
+               .resources = charger_resources,
+       },
+};
+
 static int regmap_ipc_byte_reg_read(void *context, unsigned int reg,
                                    unsigned int *val)
 {
@@ -418,6 +421,26 @@ static int bxtwc_add_chained_irq_chip(struct intel_soc_pmic *pmic,
                                        0, chip, data);
 }
 
+static int bxtwc_add_chained_devices(struct intel_soc_pmic *pmic,
+                                    const struct mfd_cell *cells, int n_devs,
+                                    struct regmap_irq_chip_data *pdata,
+                                    int pirq, int irq_flags,
+                                    const struct regmap_irq_chip *chip,
+                                    struct regmap_irq_chip_data **data)
+{
+       struct device *dev = pmic->dev;
+       struct irq_domain *domain;
+       int ret;
+
+       ret = bxtwc_add_chained_irq_chip(pmic, pdata, pirq, irq_flags, chip, data);
+       if (ret)
+               return dev_err_probe(dev, ret, "Failed to add %s IRQ chip\n", chip->name);
+
+       domain = regmap_irq_get_domain(*data);
+
+       return devm_mfd_add_devices(dev, PLATFORM_DEVID_NONE, cells, n_devs, NULL, 0, domain);
+}
+
 static int bxtwc_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
@@ -496,14 +519,14 @@ static int bxtwc_probe(struct platform_device *pdev)
        if (ret)
                return dev_err_probe(dev, ret, "Failed to add ADC IRQ chip\n");
 
-       /* Add chained IRQ handler for CHGR IRQs */
-       ret = bxtwc_add_chained_irq_chip(pmic, pmic->irq_chip_data,
-                                        BXTWC_CHGR_LVL1_IRQ,
-                                        IRQF_ONESHOT,
-                                        &bxtwc_regmap_irq_chip_chgr,
-                                        &pmic->irq_chip_data_chgr);
+       ret = bxtwc_add_chained_devices(pmic, bxt_wc_chgr_dev, ARRAY_SIZE(bxt_wc_chgr_dev),
+                                       pmic->irq_chip_data,
+                                       BXTWC_CHGR_LVL1_IRQ,
+                                       IRQF_ONESHOT,
+                                       &bxtwc_regmap_irq_chip_chgr,
+                                       &pmic->irq_chip_data_chgr);
        if (ret)
-               return dev_err_probe(dev, ret, "Failed to add CHGR IRQ chip\n");
+               return ret;
 
        /* Add chained IRQ handler for CRIT IRQs */
        ret = bxtwc_add_chained_irq_chip(pmic, pmic->irq_chip_data,
index 20917d85d6f4c3f0824cf9f944e153225cdc8e50..5d34466a0abf24caf8fea625da66a0f1baa13c95 100644 (file)
@@ -621,10 +621,6 @@ static int wcove_typec_probe(struct platform_device *pdev)
        if (irq < 0)
                return irq;
 
-       irq = regmap_irq_get_virq(pmic->irq_chip_data_chgr, irq);
-       if (irq < 0)
-               return irq;
-
        ret = guid_parse(WCOVE_DSM_UUID, &wcove->guid);
        if (ret)
                return ret;