[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250125025145.14405-3-ot_chhao.chang@mediatek.com>
Date: Sat, 25 Jan 2025 10:51:23 +0800
From: Hao Chang <ot_chhao.chang@...iatek.com>
To: Sean Wang <seann.wang@...nel.org>, Linus Walleij
<linus.walleij@...aro.org>, Matthias Brugger <matthias.bgg@...il.com>,
AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
CC: Wenbin Mei <wenbin.mei@...iatek.com>, Axe Yang <axe.yang@...iatek.com>,
Qingliang Li <qingliang.li@...iatek.com>, Hanks Chen
<hanks.chen@...iatek.com>, Chunhui Li <chunhui.li@...iatek.com>,
<linux-mediatek@...ts.infradead.org>, <linux-gpio@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <linux-arm-kernel@...ts.infradead.org>, Hao
Chang <ot_chhao.chang@...iatek.com>
Subject: [RESEND v3 2/2] pinctrl: mediatek: adapt to multi-base design
The eint num will obtain the operation address through pins.
Change the traversal method of irq handle from traversing a set of
registers to traversing one by one.
Change-Id: I3962b78042d32501a73153201cddf52c6b62a695
Signed-off-by: Hao Chang <ot_chhao.chang@...iatek.com>
Signed-off-by: Qingliang Li <qingliang.li@...iatek.com>
---
drivers/pinctrl/mediatek/mtk-eint.c | 38 +++++++++++++++++++----------
1 file changed, 25 insertions(+), 13 deletions(-)
diff --git a/drivers/pinctrl/mediatek/mtk-eint.c b/drivers/pinctrl/mediatek/mtk-eint.c
index 540245c3128d..949a20196f74 100644
--- a/drivers/pinctrl/mediatek/mtk-eint.c
+++ b/drivers/pinctrl/mediatek/mtk-eint.c
@@ -513,6 +513,7 @@ EXPORT_SYMBOL_GPL(mtk_eint_find_irq);
int mtk_eint_do_init(struct mtk_eint *eint)
{
unsigned int size, i, port;
+ struct mtk_pinctrl *hw = (struct mtk_pinctrl *)eint->pctl;
/* If clients don't assign a specific regs, let's use generic one */
if (!eint->regs)
@@ -523,11 +524,11 @@ int mtk_eint_do_init(struct mtk_eint *eint)
if (!eint->base_pin_num)
return -ENOMEM;
- if (!eint->pins) {
+ if (eint->nbase == 1) {
size = eint->hw->ap_num * sizeof(struct mtk_eint_pin);
eint->pins = devm_kmalloc(eint->dev, size, GFP_KERNEL);
if (!eint->pins)
- return -ENOMEM;
+ goto err_eint;
eint->base_pin_num[0] = eint->hw->ap_num;
for (i = 0; i < eint->hw->ap_num; i++) {
@@ -536,34 +537,29 @@ int mtk_eint_do_init(struct mtk_eint *eint)
eint->pins[i].debounce = (i < eint->hw->db_cnt) ? 1 : 0;
}
} else {
+ eint->pins = hw->soc->eint_pin;
for (i = 0; i < eint->hw->ap_num; i++)
eint->base_pin_num[eint->pins[i].instance]++;
}
eint->wake_mask = devm_kmalloc(eint->dev, eint->nbase * sizeof(u32 *), GFP_KERNEL);
- if (!eint->wake_mask)
- return -ENOMEM;
-
eint->cur_mask = devm_kmalloc(eint->dev, eint->nbase * sizeof(u32 *), GFP_KERNEL);
- if (!eint->wake_mask)
- return -ENOMEM;
+ if (!eint->wake_mask || !eint->wake_mask)
+ goto err_eint;
for (i = 0; i < eint->nbase; i++) {
port = (eint->base_pin_num[i] + 31) / 32;
eint->wake_mask[i] = devm_kzalloc(eint->dev, port * sizeof(u32), GFP_KERNEL);
- if (!eint->wake_mask[i])
- return -ENOMEM;
-
eint->cur_mask[i] = devm_kzalloc(eint->dev, port * sizeof(u32), GFP_KERNEL);
- if (!eint->cur_mask[i])
- return -ENOMEM;
+ if (!eint->cur_mask[i] || !eint->wake_mask[i])
+ goto err_eint;
}
eint->domain = irq_domain_add_linear(eint->dev->of_node,
eint->hw->ap_num,
&irq_domain_simple_ops, NULL);
if (!eint->domain)
- return -ENOMEM;
+ goto err_eint;
if (eint->hw->db_time) {
for (i = 0; i < MTK_EINT_DBNC_MAX; i++)
@@ -585,6 +581,22 @@ int mtk_eint_do_init(struct mtk_eint *eint)
eint);
return 0;
+
+err_eint:
+ for (i = 0; i < eint->nbase; i++) {
+ if (eint->wake_mask[i])
+ devm_kfree(eint->dev, eint->wake_mask[i]);
+ if (eint->cur_mask[i])
+ devm_kfree(eint->dev, eint->cur_mask[i]);
+ }
+ if (eint->cur_mask)
+ devm_kfree(eint->dev, eint->cur_mask);
+ if (eint->wake_mask)
+ devm_kfree(eint->dev, eint->wake_mask);
+ if (eint->nbase == 1)
+ devm_kfree(eint->dev, eint->pins);
+ devm_kfree(eint->dev, eint->base_pin_num);
+ return -ENOMEM;
}
EXPORT_SYMBOL_GPL(mtk_eint_do_init);
--
2.46.0
Powered by blists - more mailing lists