[PATCH 2/3] pinctrl: mediatek: Add acpi support

Lei Xue
2025-11-25T02:37:00Z

Add acpi support in the common part of pinctrl driver. Parsing
hardware base addresses and irq number to initialize eint
accroding to the acpi table data.

Signed-off-by: Lei Xue <lei.xue@mediatek.com>
---
.../pinctrl/mediatek/pinctrl-mtk-common-v2.c | 24 +++++++++++++++----
drivers/pinctrl/mediatek/pinctrl-paris.c | 6 +++--
2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index 4918d38abfc2..afa406afead2 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -369,18 +369,30 @@ int mtk_build_eint(struct mtk_pinctrl *hw, struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
int ret, i, j, count_reg_names;
+ struct fwnode_handle *fwnode = dev_fwnode(&pdev->dev);
+ struct resource *res;

if (!IS_ENABLED(CONFIG_EINT_MTK))
return 0;

- if (!of_property_read_bool(np, "interrupt-controller"))
+ if (is_of_node(fwnode) && !of_property_read_bool(np, "interrupt-controller"))
return -ENODEV;

hw->eint = devm_kzalloc(hw->dev, sizeof(*hw->eint), GFP_KERNEL);
if (!hw->eint)
return -ENOMEM;

- count_reg_names = of_property_count_strings(np, "reg-names");
+ if (is_of_node(fwnode)) {
+ count_reg_names = of_property_count_strings(np, "reg-names");
+ } else {
+ count_reg_names = 0;
+ for (i = 0; i < pdev->num_resources; i++) {
+ struct resource *r = &pdev->resource[i];
+
+ if (resource_type(r) == IORESOURCE_MEM)
+ count_reg_names++;
+ }
+ }
if (count_reg_names < 0)
return -EINVAL;

@@ -396,14 +408,18 @@ int mtk_build_eint(struct mtk_pinctrl *hw, struct platform_device *pdev)
}

for (i = hw->soc->nbase_names, j = 0; i < count_reg_names; i++, j++) {
- hw->eint->base[j] = of_iomap(np, i);
+ res = platform_get_resource(pdev, IORESOURCE_MEM, i);
+ hw->eint->base[j] = is_of_node(fwnode) ? of_iomap(np, i) :
+ ioremap(res->start, resource_size(res));
if (IS_ERR(hw->eint->base[j])) {
ret = PTR_ERR(hw->eint->base[j]);
goto err_free_eint;
}
}

- hw->eint->irq = irq_of_parse_and_map(np, 0);
+ hw->eint->irq = is_of_node(fwnode)
+ ? irq_of_parse_and_map(np, 0)
+ : platform_get_irq(pdev, 0);
if (!hw->eint->irq) {
ret = -EINVAL;
goto err_free_eint;
diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c
index 2cf61cfe809e..9c2751b9b065 100644
--- a/drivers/pinctrl/mediatek/pinctrl-paris.c
+++ b/drivers/pinctrl/mediatek/pinctrl-paris.c
@@ -1008,6 +1008,7 @@ int mtk_paris_pinctrl_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct pinctrl_pin_desc *pins;
struct mtk_pinctrl *hw;
+ struct fwnode_handle *fwnode = dev_fwnode(&pdev->dev);
int err, i;

hw = devm_kzalloc(&pdev->dev, sizeof(*hw), GFP_KERNEL);
@@ -1032,8 +1033,9 @@ int mtk_paris_pinctrl_probe(struct platform_device *pdev)
return -ENOMEM;

for (i = 0; i < hw->soc->nbase_names; i++) {
- hw->base[i] = devm_platform_ioremap_resource_byname(pdev,
- hw->soc->base_names[i]);
+ hw->base[i] = is_of_node(fwnode)
+ ? devm_platform_ioremap_resource_byname(pdev, hw->soc->base_names[i])
+ : devm_platform_get_and_ioremap_resource(pdev, i, NULL);
if (IS_ERR(hw->base[i]))
return PTR_ERR(hw->base[i]);
}
--
2.45.2