@@ -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;
@@ -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);