Change the method of obtaining the EINT base from a single value to multiple values. Modify the EINT base and add nbase for counting. Signed-off-by: Hao Chang <ot_chhao.chang@xxxxxxxxxxxx> Signed-off-by: Qingliang Li <qingliang.li@xxxxxxxxxxxx> --- drivers/pinctrl/mediatek/mtk-eint.h | 4 +- .../pinctrl/mediatek/pinctrl-mtk-common-v2.c | 45 ++++++++++--------- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/drivers/pinctrl/mediatek/mtk-eint.h b/drivers/pinctrl/mediatek/mtk-eint.h index 44360d97a34a..c1efdf02fb49 100644 --- a/drivers/pinctrl/mediatek/mtk-eint.h +++ b/drivers/pinctrl/mediatek/mtk-eint.h @@ -64,7 +64,9 @@ struct mtk_eint_xt { struct mtk_eint { struct device *dev; - void __iomem *base; + void __iomem **base; + u8 nbase; + u16 *base_pin_num; struct irq_domain *domain; int irq; diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c index 00e95682b9f8..6411c10cb637 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c @@ -13,6 +13,7 @@ #include <linux/platform_device.h> #include <linux/io.h> #include <linux/module.h> +#include <linux/of_address.h> #include <linux/of_irq.h> #include "mtk-eint.h" @@ -367,34 +368,43 @@ static const struct mtk_eint_xt mtk_eint_xt = { int mtk_build_eint(struct mtk_pinctrl *hw, struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; - int ret; + unsigned int i, j, count_reg_names; if (!IS_ENABLED(CONFIG_EINT_MTK)) return 0; - if (!of_property_read_bool(np, "interrupt-controller")) + if (!hw->soc->eint_hw) return -ENODEV; - hw->eint = devm_kzalloc(hw->dev, sizeof(*hw->eint), GFP_KERNEL); + count_reg_names = of_property_count_strings(np, "reg-names"); + if (count_reg_names < 0 || count_reg_names < hw->soc->nbase_names) + return -EINVAL; + + hw->eint = devm_kmalloc(hw->dev, sizeof(*hw->eint), GFP_KERNEL); if (!hw->eint) return -ENOMEM; - hw->eint->base = devm_platform_ioremap_resource_byname(pdev, "eint"); - if (IS_ERR(hw->eint->base)) { - ret = PTR_ERR(hw->eint->base); - goto err_free_eint; + hw->eint->nbase = count_reg_names - hw->soc->nbase_names; + hw->eint->base = devm_kmalloc_array(&pdev->dev, hw->eint->nbase, + sizeof(*hw->eint->base), GFP_KERNEL); + if (!hw->eint->base) + return -ENOMEM; + + for (i = hw->soc->nbase_names, j = 0; i < count_reg_names; i++, j++) { + hw->eint->base[j] = of_iomap(np, i); + if (IS_ERR(hw->eint->base[j])) + return PTR_ERR(hw->eint->base[j]); } + if (!of_property_read_bool(np, "interrupt-controller")) + return -ENODEV; + hw->eint->irq = irq_of_parse_and_map(np, 0); - if (!hw->eint->irq) { - ret = -EINVAL; - goto err_free_eint; - } + if (!hw->eint->irq) + return -EINVAL; - if (!hw->soc->eint_hw) { - ret = -ENODEV; - goto err_free_eint; - } + if (hw->soc->eint_pin) + hw->eint->pins = hw->soc->eint_pin; hw->eint->dev = &pdev->dev; hw->eint->hw = hw->soc->eint_hw; @@ -402,11 +412,6 @@ int mtk_build_eint(struct mtk_pinctrl *hw, struct platform_device *pdev) hw->eint->gpio_xlate = &mtk_eint_xt; return mtk_eint_do_init(hw->eint); - -err_free_eint: - devm_kfree(hw->dev, hw->eint); - hw->eint = NULL; - return ret; } EXPORT_SYMBOL_GPL(mtk_build_eint); -- 2.34.1