* [PATCH v4 0/3] Add EINT support for multiple addresses
@ 2025-02-25 14:07 Hao Chang
2025-02-25 14:07 ` [PATCH v4 1/3] pinctrl: mediatek: add eint pins Hao Chang
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Hao Chang @ 2025-02-25 14:07 UTC (permalink / raw)
To: Sean Wang, Linus Walleij, Matthias Brugger,
AngeloGioacchino Del Regno
Cc: Wenbin Mei, Axe Yang, Qingliang Li, Hanks Chen, Chunhui Li,
linux-mediatek, linux-gpio, linux-kernel, linux-arm-kernel,
Hao Chang
v4 changes:
1)Add err statement for exception handling
2)Add check for invalid pins
3)Use defined eint pins
v3 changes:
1)Add error judgment
v2 changes:
1)Remove instance structure
2)Modify the way to obtain eint address
---
This patch depends on
[v3,2/2] pinctrl: mediatek: add mt8196 driver
[v3,1/2] dt-bindings: pinctrl: mediatek: add support for mt8196
Please also accept this patch together with [1]
to avoid build and dt binding check error.
[1]https://patchwork.kernel.org/project/linux-mediatek/list/?series=&submitter=215008&state=&q=v3&archive=&delegate=
---
Hao Chang (3):
pinctrl: mediatek: add eint pins
inctrl: mediatek: modify the method of obtaining eint address
pinctrl: mediatek: adapt to EINT multi-segment addresses
drivers/pinctrl/mediatek/mtk-eint.c | 246 ++++++++++-----
drivers/pinctrl/mediatek/mtk-eint.h | 21 +-
drivers/pinctrl/mediatek/pinctrl-mt8196.c | 1 +
.../pinctrl/mediatek/pinctrl-mtk-common-v2.c | 49 ++-
.../pinctrl/mediatek/pinctrl-mtk-common-v2.h | 1 +
drivers/pinctrl/mediatek/pinctrl-mtk-mt8196.h | 296 ++++++++++++++++++
drivers/pinctrl/mediatek/pinctrl-paris.h | 7 +
7 files changed, 518 insertions(+), 103 deletions(-)
--
2.46.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v4 1/3] pinctrl: mediatek: add eint pins
2025-02-25 14:07 [PATCH v4 0/3] Add EINT support for multiple addresses Hao Chang
@ 2025-02-25 14:07 ` Hao Chang
2025-02-25 14:07 ` [PATCH v4 2/3] pinctrl: mediatek: modify the method of obtaining eint address Hao Chang
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Hao Chang @ 2025-02-25 14:07 UTC (permalink / raw)
To: Sean Wang, Linus Walleij, Matthias Brugger,
AngeloGioacchino Del Regno
Cc: Wenbin Mei, Axe Yang, Qingliang Li, Hanks Chen, Chunhui Li,
linux-mediatek, linux-gpio, linux-kernel, linux-arm-kernel,
Hao Chang
Define eint pins to store the pin information for each address.
Signed-off-by: Hao Chang <ot_chhao.chang@mediatek.com>
Signed-off-by: Qingliang Li <qingliang.li@mediatek.com>
---
drivers/pinctrl/mediatek/mtk-eint.h | 9 +
drivers/pinctrl/mediatek/pinctrl-mt8196.c | 1 +
.../pinctrl/mediatek/pinctrl-mtk-common-v2.h | 1 +
drivers/pinctrl/mediatek/pinctrl-mtk-mt8196.h | 296 ++++++++++++++++++
drivers/pinctrl/mediatek/pinctrl-paris.h | 7 +
5 files changed, 314 insertions(+)
diff --git a/drivers/pinctrl/mediatek/mtk-eint.h b/drivers/pinctrl/mediatek/mtk-eint.h
index 6139b16cd225..44360d97a34a 100644
--- a/drivers/pinctrl/mediatek/mtk-eint.h
+++ b/drivers/pinctrl/mediatek/mtk-eint.h
@@ -40,6 +40,14 @@ struct mtk_eint_hw {
const unsigned int *db_time;
};
+struct mtk_eint_pin {
+ u16 number;
+ u8 instance;
+ u8 index;
+ bool debounce;
+ bool dual_edge;
+};
+
extern const unsigned int debounce_time_mt2701[];
extern const unsigned int debounce_time_mt6765[];
extern const unsigned int debounce_time_mt6795[];
@@ -67,6 +75,7 @@ struct mtk_eint {
/* Used to fit into various EINT device */
const struct mtk_eint_hw *hw;
const struct mtk_eint_regs *regs;
+ struct mtk_eint_pin *pins;
u16 num_db_time;
/* Used to fit into various pinctrl device */
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8196.c b/drivers/pinctrl/mediatek/pinctrl-mt8196.c
index 822ceb8dc268..89be051e6c91 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt8196.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt8196.c
@@ -1728,6 +1728,7 @@ static const struct mtk_pin_soc mt8196_data = {
.npins = ARRAY_SIZE(mtk_pins_mt8196),
.ngrps = ARRAY_SIZE(mtk_pins_mt8196),
.eint_hw = &mt8196_eint_hw,
+ .eint_pin = eint_pins_mt8196,
.nfuncs = 8,
.gpio_m = 0,
.base_names = mt8196_pinctrl_register_base_names,
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
index 9c271dc2b521..36d2898037dd 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
@@ -242,6 +242,7 @@ struct mtk_pin_soc {
unsigned int nfuncs;
const struct mtk_eint_regs *eint_regs;
const struct mtk_eint_hw *eint_hw;
+ struct mtk_eint_pin *eint_pin;
/* Specific parameters per SoC */
u8 gpio_m;
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-mt8196.h b/drivers/pinctrl/mediatek/pinctrl-mtk-mt8196.h
index d342d091672c..8abab0da72d6 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-mt8196.h
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-mt8196.h
@@ -8,6 +8,7 @@
#define __PINCTRL_MTK_MT8196_H
#include "pinctrl-paris.h"
+#define INVALID_BASE 0xff
static const struct mtk_pin_desc mtk_pins_mt8196[] = {
MTK_PIN(
@@ -2786,4 +2787,299 @@ static const struct mtk_pin_desc mtk_pins_mt8196[] = {
)
};
+static struct mtk_eint_pin eint_pins_mt8196[] = {
+ MTK_EINT_PIN(0, 2, 0, 1),
+ MTK_EINT_PIN(1, 2, 1, 1),
+ MTK_EINT_PIN(2, 2, 16, 0),
+ MTK_EINT_PIN(3, 2, 17, 0),
+ MTK_EINT_PIN(4, 2, 2, 1),
+ MTK_EINT_PIN(5, 2, 3, 1),
+ MTK_EINT_PIN(6, 2, 4, 1),
+ MTK_EINT_PIN(7, 2, 5, 1),
+ MTK_EINT_PIN(8, 2, 6, 1),
+ MTK_EINT_PIN(9, 2, 18, 0),
+ MTK_EINT_PIN(10, 2, 7, 1),
+ MTK_EINT_PIN(11, 2, 8, 1),
+ MTK_EINT_PIN(12, 2, 9, 1),
+ MTK_EINT_PIN(13, 1, 4, 0),
+ MTK_EINT_PIN(14, 0, 0, 1),
+ MTK_EINT_PIN(15, 1, 5, 0),
+ MTK_EINT_PIN(16, 1, 6, 0),
+ MTK_EINT_PIN(17, 1, 7, 0),
+ MTK_EINT_PIN(18, 1, 8, 0),
+ MTK_EINT_PIN(19, 1, 9, 0),
+ MTK_EINT_PIN(20, 0, 1, 1),
+ MTK_EINT_PIN(21, 0, 10, 0),
+ MTK_EINT_PIN(22, 0, 11, 0),
+ MTK_EINT_PIN(23, 0, 12, 0),
+ MTK_EINT_PIN(24, 0, 13, 0),
+ MTK_EINT_PIN(25, 0, 14, 0),
+ MTK_EINT_PIN(26, 0, 15, 0),
+ MTK_EINT_PIN(27, 0, 2, 1),
+ MTK_EINT_PIN(28, 0, 16, 0),
+ MTK_EINT_PIN(29, 0, 17, 0),
+ MTK_EINT_PIN(30, 0, 18, 0),
+ MTK_EINT_PIN(31, 0, 3, 1),
+ MTK_EINT_PIN(32, 0, 19, 0),
+ MTK_EINT_PIN(33, 0, 20, 0),
+ MTK_EINT_PIN(34, 0, 21, 0),
+ MTK_EINT_PIN(35, 0, 22, 0),
+ MTK_EINT_PIN(36, 0, 23, 0),
+ MTK_EINT_PIN(37, 0, 24, 0),
+ MTK_EINT_PIN(38, 0, 25, 0),
+ MTK_EINT_PIN(39, 2, 10, 1),
+ MTK_EINT_PIN(40, 2, 11, 1),
+ MTK_EINT_PIN(41, 2, 12, 1),
+ MTK_EINT_PIN(42, 2, 13, 1),
+ MTK_EINT_PIN(43, 2, 14, 1),
+ MTK_EINT_PIN(44, 2, 19, 0),
+ MTK_EINT_PIN(45, 2, 20, 0),
+ MTK_EINT_PIN(46, 2, 21, 0),
+ MTK_EINT_PIN(47, 2, 22, 0),
+ MTK_EINT_PIN(48, 2, 23, 0),
+ MTK_EINT_PIN(49, 2, 24, 0),
+ MTK_EINT_PIN(50, 2, 25, 0),
+ MTK_EINT_PIN(51, 2, 26, 0),
+ MTK_EINT_PIN(52, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(53, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(54, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(55, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(56, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(57, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(58, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(59, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(60, 2, 27, 0),
+ MTK_EINT_PIN(61, 2, 28, 0),
+ MTK_EINT_PIN(62, 2, 29, 0),
+ MTK_EINT_PIN(63, 2, 30, 0),
+ MTK_EINT_PIN(64, 2, 31, 0),
+ MTK_EINT_PIN(65, 2, 32, 0),
+ MTK_EINT_PIN(66, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(67, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(68, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(69, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(70, 2, 33, 0),
+ MTK_EINT_PIN(71, 2, 34, 0),
+ MTK_EINT_PIN(72, 2, 35, 0),
+ MTK_EINT_PIN(73, 2, 36, 0),
+ MTK_EINT_PIN(74, 2, 37, 0),
+ MTK_EINT_PIN(75, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(76, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(77, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(78, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(79, 2, 38, 0),
+ MTK_EINT_PIN(80, 2, 39, 0),
+ MTK_EINT_PIN(81, 2, 40, 0),
+ MTK_EINT_PIN(82, 2, 41, 0),
+ MTK_EINT_PIN(83, 2, 42, 0),
+ MTK_EINT_PIN(84, 2, 43, 0),
+ MTK_EINT_PIN(85, 2, 44, 0),
+ MTK_EINT_PIN(86, 2, 45, 0),
+ MTK_EINT_PIN(87, 2, 46, 0),
+ MTK_EINT_PIN(88, 2, 47, 0),
+ MTK_EINT_PIN(89, 2, 48, 0),
+ MTK_EINT_PIN(90, 2, 49, 0),
+ MTK_EINT_PIN(91, 2, 50, 0),
+ MTK_EINT_PIN(92, 2, 15, 1),
+ MTK_EINT_PIN(93, 2, 51, 0),
+ MTK_EINT_PIN(94, 2, 52, 0),
+ MTK_EINT_PIN(95, 2, 53, 0),
+ MTK_EINT_PIN(96, 2, 54, 0),
+ MTK_EINT_PIN(97, 2, 55, 0),
+ MTK_EINT_PIN(98, 2, 56, 0),
+ MTK_EINT_PIN(99, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(100, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(101, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(102, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(103, 2, 57, 0),
+ MTK_EINT_PIN(104, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(105, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(106, 1, 10, 0),
+ MTK_EINT_PIN(107, 1, 11, 0),
+ MTK_EINT_PIN(108, 1, 12, 0),
+ MTK_EINT_PIN(109, 1, 13, 0),
+ MTK_EINT_PIN(110, 1, 0, 1),
+ MTK_EINT_PIN(111, 1, 1, 1),
+ MTK_EINT_PIN(112, 1, 2, 1),
+ MTK_EINT_PIN(113, 1, 3, 1),
+ MTK_EINT_PIN(114, 1, 14, 0),
+ MTK_EINT_PIN(115, 1, 15, 0),
+ MTK_EINT_PIN(116, 1, 16, 0),
+ MTK_EINT_PIN(117, 1, 17, 0),
+ MTK_EINT_PIN(118, 1, 18, 0),
+ MTK_EINT_PIN(119, 1, 19, 0),
+ MTK_EINT_PIN(120, 1, 20, 0),
+ MTK_EINT_PIN(121, 1, 21, 0),
+ MTK_EINT_PIN(122, 1, 22, 0),
+ MTK_EINT_PIN(123, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(124, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(125, 1, 23, 0),
+ MTK_EINT_PIN(126, 1, 24, 0),
+ MTK_EINT_PIN(127, 1, 25, 0),
+ MTK_EINT_PIN(128, 1, 26, 0),
+ MTK_EINT_PIN(129, 1, 27, 0),
+ MTK_EINT_PIN(130, 1, 28, 0),
+ MTK_EINT_PIN(131, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(132, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(133, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(134, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(135, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(136, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(137, 0, 26, 0),
+ MTK_EINT_PIN(138, 0, 27, 0),
+ MTK_EINT_PIN(139, 0, 28, 0),
+ MTK_EINT_PIN(140, 0, 29, 0),
+ MTK_EINT_PIN(141, 0, 30, 0),
+ MTK_EINT_PIN(142, 0, 31, 0),
+ MTK_EINT_PIN(143, 0, 32, 0),
+ MTK_EINT_PIN(144, 0, 33, 0),
+ MTK_EINT_PIN(145, 0, 34, 0),
+ MTK_EINT_PIN(146, 0, 35, 0),
+ MTK_EINT_PIN(147, 0, 36, 0),
+ MTK_EINT_PIN(148, 0, 4, 1),
+ MTK_EINT_PIN(149, 0, 37, 0),
+ MTK_EINT_PIN(150, 0, 5, 1),
+ MTK_EINT_PIN(151, 0, 38, 0),
+ MTK_EINT_PIN(152, 0, 39, 0),
+ MTK_EINT_PIN(153, 0, 40, 0),
+ MTK_EINT_PIN(154, 0, 41, 0),
+ MTK_EINT_PIN(155, 0, 42, 0),
+ MTK_EINT_PIN(156, 0, 43, 0),
+ MTK_EINT_PIN(157, 0, 44, 0),
+ MTK_EINT_PIN(158, 0, 45, 0),
+ MTK_EINT_PIN(159, 0, 46, 0),
+ MTK_EINT_PIN(160, 0, 47, 0),
+ MTK_EINT_PIN(161, 0, 48, 0),
+ MTK_EINT_PIN(162, 0, 49, 0),
+ MTK_EINT_PIN(163, 0, 50, 0),
+ MTK_EINT_PIN(164, 0, 51, 0),
+ MTK_EINT_PIN(165, 0, 52, 0),
+ MTK_EINT_PIN(166, 0, 53, 0),
+ MTK_EINT_PIN(167, 0, 54, 0),
+ MTK_EINT_PIN(168, 0, 55, 0),
+ MTK_EINT_PIN(169, 0, 56, 0),
+ MTK_EINT_PIN(170, 0, 57, 0),
+ MTK_EINT_PIN(171, 0, 58, 0),
+ MTK_EINT_PIN(172, 0, 6, 1),
+ MTK_EINT_PIN(173, 0, 7, 1),
+ MTK_EINT_PIN(174, 0, 8, 1),
+ MTK_EINT_PIN(175, 0, 9, 1),
+ MTK_EINT_PIN(176, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(177, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(178, 0, 59, 0),
+ MTK_EINT_PIN(179, 0, 60, 0),
+ MTK_EINT_PIN(180, 0, 61, 0),
+ MTK_EINT_PIN(181, 0, 62, 0),
+ MTK_EINT_PIN(182, 0, 63, 0),
+ MTK_EINT_PIN(183, 0, 64, 0),
+ MTK_EINT_PIN(184, 0, 65, 0),
+ MTK_EINT_PIN(185, 0, 66, 0),
+ MTK_EINT_PIN(186, 3, 6, 0),
+ MTK_EINT_PIN(187, 3, 7, 0),
+ MTK_EINT_PIN(188, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(189, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(190, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(191, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(192, 3, 8, 0),
+ MTK_EINT_PIN(193, 3, 9, 0),
+ MTK_EINT_PIN(194, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(195, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(196, 3, 10, 0),
+ MTK_EINT_PIN(197, 3, 11, 0),
+ MTK_EINT_PIN(198, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(199, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(200, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(201, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(202, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(203, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(204, 3, 12, 0),
+ MTK_EINT_PIN(205, 3, 13, 0),
+ MTK_EINT_PIN(206, 3, 14, 0),
+ MTK_EINT_PIN(207, 3, 0, 1),
+ MTK_EINT_PIN(208, 3, 1, 1),
+ MTK_EINT_PIN(209, 3, 2, 1),
+ MTK_EINT_PIN(210, 3, 15, 0),
+ MTK_EINT_PIN(211, 3, 3, 1),
+ MTK_EINT_PIN(212, 3, 4, 1),
+ MTK_EINT_PIN(213, 3, 5, 1),
+ MTK_EINT_PIN(214, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(215, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(216, 3, 16, 0),
+ MTK_EINT_PIN(217, 3, 17, 0),
+ MTK_EINT_PIN(218, 3, 18, 0),
+ MTK_EINT_PIN(219, 3, 19, 0),
+ MTK_EINT_PIN(220, 3, 20, 0),
+ MTK_EINT_PIN(221, 3, 21, 0),
+ MTK_EINT_PIN(222, 3, 22, 0),
+ MTK_EINT_PIN(223, 3, 23, 0),
+ MTK_EINT_PIN(224, 3, 24, 0),
+ MTK_EINT_PIN(225, 3, 25, 0),
+ MTK_EINT_PIN(226, 3, 26, 0),
+ MTK_EINT_PIN(227, 3, 27, 0),
+ MTK_EINT_PIN(228, 3, 28, 0),
+ MTK_EINT_PIN(229, 3, 29, 0),
+ MTK_EINT_PIN(230, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(231, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(232, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(233, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(234, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(235, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(236, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(237, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(238, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(239, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(240, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(241, 3, 30, 0),
+ MTK_EINT_PIN(242, 3, 31, 0),
+ MTK_EINT_PIN(243, 3, 32, 0),
+ MTK_EINT_PIN(244, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(245, 3, 45, 0),
+ MTK_EINT_PIN(246, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(247, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(248, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(249, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(250, INVALID_BASE, 0, 0),
+ MTK_EINT_PIN(251, 0, 67, 0),
+ MTK_EINT_PIN(252, 0, 68, 0),
+ MTK_EINT_PIN(253, 0, 69, 0),
+ MTK_EINT_PIN(254, 0, 70, 0),
+ MTK_EINT_PIN(255, 0, 71, 0),
+ MTK_EINT_PIN(256, 0, 72, 0),
+ MTK_EINT_PIN(257, 0, 73, 0),
+ MTK_EINT_PIN(258, 0, 74, 0),
+ MTK_EINT_PIN(259, 3, 33, 0),
+ MTK_EINT_PIN(260, 3, 34, 0),
+ MTK_EINT_PIN(261, 3, 35, 0),
+ MTK_EINT_PIN(262, 3, 36, 0),
+ MTK_EINT_PIN(263, 3, 37, 0),
+ MTK_EINT_PIN(264, 3, 38, 0),
+ MTK_EINT_PIN(265, 3, 39, 0),
+ MTK_EINT_PIN(266, 3, 40, 0),
+ MTK_EINT_PIN(267, 3, 41, 0),
+ MTK_EINT_PIN(268, 3, 42, 0),
+ MTK_EINT_PIN(269, 3, 43, 0),
+ MTK_EINT_PIN(270, 3, 44, 0),
+ MTK_EINT_PIN(271, 4, 0, 0),
+ MTK_EINT_PIN(272, 4, 1, 0),
+ MTK_EINT_PIN(273, 4, 2, 0),
+ MTK_EINT_PIN(274, 4, 3, 0),
+ MTK_EINT_PIN(275, 4, 4, 0),
+ MTK_EINT_PIN(276, 4, 5, 0),
+ MTK_EINT_PIN(277, 4, 6, 0),
+ MTK_EINT_PIN(278, 4, 7, 0),
+ MTK_EINT_PIN(279, 4, 8, 0),
+ MTK_EINT_PIN(280, 4, 9, 0),
+ MTK_EINT_PIN(281, 4, 10, 0),
+ MTK_EINT_PIN(282, 4, 11, 0),
+ MTK_EINT_PIN(283, 4, 12, 0),
+ MTK_EINT_PIN(284, 4, 13, 0),
+ MTK_EINT_PIN(285, 4, 14, 0),
+ MTK_EINT_PIN(286, 4, 15, 0),
+ MTK_EINT_PIN(287, 4, 16, 0),
+ MTK_EINT_PIN(288, 4, 17, 0),
+ MTK_EINT_PIN(289, 4, 18, 0),
+ MTK_EINT_PIN(290, 4, 19, 0),
+ MTK_EINT_PIN(291, 4, 20, 0),
+ MTK_EINT_PIN(292, 4, 21, 0),
+};
#endif /* __PINCTRL_MTK_MT8196_H */
diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.h b/drivers/pinctrl/mediatek/pinctrl-paris.h
index 948ce126aa0c..d8c1822662fc 100644
--- a/drivers/pinctrl/mediatek/pinctrl-paris.h
+++ b/drivers/pinctrl/mediatek/pinctrl-paris.h
@@ -49,6 +49,13 @@
__VA_ARGS__, { } }, \
}
+#define MTK_EINT_PIN(_number, _instance, _index, _debounce) { \
+ .number = _number, \
+ .instance = _instance, \
+ .index = _index, \
+ .debounce = _debounce, \
+ }
+
#define PINCTRL_PIN_GROUP(_name_, id) \
{ \
.grp = PINCTRL_PINGROUP(_name_,id##_pins, ARRAY_SIZE(id##_pins)), \
--
2.46.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v4 2/3] pinctrl: mediatek: modify the method of obtaining eint address
2025-02-25 14:07 [PATCH v4 0/3] Add EINT support for multiple addresses Hao Chang
2025-02-25 14:07 ` [PATCH v4 1/3] pinctrl: mediatek: add eint pins Hao Chang
@ 2025-02-25 14:07 ` Hao Chang
2025-02-25 14:07 ` [PATCH v4 3/3] pinctrl: mediatek: adapt to EINT multi-segment addresses Hao Chang
2025-03-14 9:58 ` [PATCH v4 0/3] Add EINT support for multiple addresses Linus Walleij
3 siblings, 0 replies; 6+ messages in thread
From: Hao Chang @ 2025-02-25 14:07 UTC (permalink / raw)
To: Sean Wang, Linus Walleij, Matthias Brugger,
AngeloGioacchino Del Regno
Cc: Wenbin Mei, Axe Yang, Qingliang Li, Hanks Chen, Chunhui Li,
linux-mediatek, linux-gpio, linux-kernel, linux-arm-kernel,
Hao Chang
Increase nbase for address counting and pin number for calculating
pin count on address.
Signed-off-by: Hao Chang <ot_chhao.chang@mediatek.com>
Signed-off-by: Qingliang Li <qingliang.li@mediatek.com>
---
drivers/pinctrl/mediatek/mtk-eint.h | 4 +-
.../pinctrl/mediatek/pinctrl-mtk-common-v2.c | 49 ++++++++++++++-----
2 files changed, 40 insertions(+), 13 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..9e87dddafb12 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,21 +368,40 @@ 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;
+ int ret, 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 < 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);
+ 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 | __GFP_ZERO);
+ if (!hw->eint->base) {
+ ret = -ENOMEM;
+ goto err_free_base;
+ }
+
+ 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])) {
+ ret = PTR_ERR(hw->eint->base[j]);
+ goto err_free_eint;
+ }
+ }
+
+ if (!of_property_read_bool(np, "interrupt-controller")) {
+ ret = -ENODEV;
goto err_free_eint;
}
@@ -391,19 +411,24 @@ int mtk_build_eint(struct mtk_pinctrl *hw, struct platform_device *pdev)
goto err_free_eint;
}
- if (!hw->soc->eint_hw) {
- ret = -ENODEV;
- goto err_free_eint;
- }
-
hw->eint->dev = &pdev->dev;
hw->eint->hw = hw->soc->eint_hw;
hw->eint->pctl = hw;
hw->eint->gpio_xlate = &mtk_eint_xt;
- return mtk_eint_do_init(hw->eint);
+ ret = mtk_eint_do_init(hw->eint);
+ if (ret)
+ goto err_free_eint;
+
+ return 0;
err_free_eint:
+ for (j = 0; j < hw->eint->nbase; j++) {
+ if (hw->eint->base[j])
+ iounmap(hw->eint->base[j]);
+ }
+ devm_kfree(hw->dev, hw->eint->base);
+err_free_base:
devm_kfree(hw->dev, hw->eint);
hw->eint = NULL;
return ret;
--
2.46.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v4 3/3] pinctrl: mediatek: adapt to EINT multi-segment addresses
2025-02-25 14:07 [PATCH v4 0/3] Add EINT support for multiple addresses Hao Chang
2025-02-25 14:07 ` [PATCH v4 1/3] pinctrl: mediatek: add eint pins Hao Chang
2025-02-25 14:07 ` [PATCH v4 2/3] pinctrl: mediatek: modify the method of obtaining eint address Hao Chang
@ 2025-02-25 14:07 ` Hao Chang
2025-03-14 9:58 ` [PATCH v4 0/3] Add EINT support for multiple addresses Linus Walleij
3 siblings, 0 replies; 6+ messages in thread
From: Hao Chang @ 2025-02-25 14:07 UTC (permalink / raw)
To: Sean Wang, Linus Walleij, Matthias Brugger,
AngeloGioacchino Del Regno
Cc: Wenbin Mei, Axe Yang, Qingliang Li, Hanks Chen, Chunhui Li,
linux-mediatek, linux-gpio, linux-kernel, linux-arm-kernel,
Hao Chang, kernel test robot
The eint num will obtain the operation address through pins.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202412021959.txWIlGI0-lkp@intel.com/
Signed-off-by: Hao Chang <ot_chhao.chang@mediatek.com>
Signed-off-by: Qingliang Li <qingliang.li@mediatek.com>
---
drivers/pinctrl/mediatek/mtk-eint.c | 246 ++++++++++++++++++----------
drivers/pinctrl/mediatek/mtk-eint.h | 8 +-
2 files changed, 164 insertions(+), 90 deletions(-)
diff --git a/drivers/pinctrl/mediatek/mtk-eint.c b/drivers/pinctrl/mediatek/mtk-eint.c
index 27f0a54e12bf..dafcbeff9506 100644
--- a/drivers/pinctrl/mediatek/mtk-eint.c
+++ b/drivers/pinctrl/mediatek/mtk-eint.c
@@ -1,11 +1,13 @@
// SPDX-License-Identifier: GPL-2.0
-// Copyright (c) 2014-2018 MediaTek Inc.
+// Copyright (c) 2014-2025 MediaTek Inc.
/*
* Library for MediaTek External Interrupt Support
*
* Author: Maoguang Meng <maoguang.meng@mediatek.com>
* Sean Wang <sean.wang@mediatek.com>
+ * Hao Chang <ot_chhao.chang@mediatek.com>
+ * Qingliang Li <qingliang.li@mediatek.com>
*
*/
@@ -20,6 +22,7 @@
#include <linux/platform_device.h>
#include "mtk-eint.h"
+#include "pinctrl-mtk-common-v2.h"
#define MTK_EINT_EDGE_SENSITIVE 0
#define MTK_EINT_LEVEL_SENSITIVE 1
@@ -68,13 +71,11 @@ static void __iomem *mtk_eint_get_offset(struct mtk_eint *eint,
unsigned int eint_num,
unsigned int offset)
{
- unsigned int eint_base = 0;
+ unsigned int idx = eint->pins[eint_num].index;
+ unsigned int inst = eint->pins[eint_num].instance;
void __iomem *reg;
- if (eint_num >= eint->hw->ap_num)
- eint_base = eint->hw->ap_num;
-
- reg = eint->base + offset + ((eint_num - eint_base) / 32) * 4;
+ reg = eint->base[inst] + offset + (idx / 32 * 4);
return reg;
}
@@ -83,7 +84,7 @@ static unsigned int mtk_eint_can_en_debounce(struct mtk_eint *eint,
unsigned int eint_num)
{
unsigned int sens;
- unsigned int bit = BIT(eint_num % 32);
+ unsigned int bit = BIT(eint->pins[eint_num].index % 32);
void __iomem *reg = mtk_eint_get_offset(eint, eint_num,
eint->regs->sens);
@@ -92,7 +93,7 @@ static unsigned int mtk_eint_can_en_debounce(struct mtk_eint *eint,
else
sens = MTK_EINT_EDGE_SENSITIVE;
- if (eint_num < eint->hw->db_cnt && sens != MTK_EINT_EDGE_SENSITIVE)
+ if (eint->pins[eint_num].debounce && sens != MTK_EINT_EDGE_SENSITIVE)
return 1;
else
return 0;
@@ -102,9 +103,9 @@ static int mtk_eint_flip_edge(struct mtk_eint *eint, int hwirq)
{
int start_level, curr_level;
unsigned int reg_offset;
- u32 mask = BIT(hwirq & 0x1f);
- u32 port = (hwirq >> 5) & eint->hw->port_mask;
- void __iomem *reg = eint->base + (port << 2);
+ unsigned int mask = BIT(eint->pins[hwirq].index & 0x1f);
+ unsigned int port = (eint->pins[hwirq].index >> 5) & eint->hw->port_mask;
+ void __iomem *reg = eint->base[eint->pins[hwirq].instance] + (port << 2);
curr_level = eint->gpio_xlate->get_gpio_state(eint->pctl, hwirq);
@@ -126,11 +127,13 @@ static int mtk_eint_flip_edge(struct mtk_eint *eint, int hwirq)
static void mtk_eint_mask(struct irq_data *d)
{
struct mtk_eint *eint = irq_data_get_irq_chip_data(d);
- u32 mask = BIT(d->hwirq & 0x1f);
+ u32 idx = eint->pins[d->hwirq].index;
+ u32 inst = eint->pins[d->hwirq].instance;
+ u32 mask = BIT(idx & 0x1f);
void __iomem *reg = mtk_eint_get_offset(eint, d->hwirq,
eint->regs->mask_set);
- eint->cur_mask[d->hwirq >> 5] &= ~mask;
+ eint->cur_mask[inst][idx >> 5] &= ~mask;
writel(mask, reg);
}
@@ -138,32 +141,44 @@ static void mtk_eint_mask(struct irq_data *d)
static void mtk_eint_unmask(struct irq_data *d)
{
struct mtk_eint *eint = irq_data_get_irq_chip_data(d);
- u32 mask = BIT(d->hwirq & 0x1f);
+ u32 idx = eint->pins[d->hwirq].index;
+ u32 inst = eint->pins[d->hwirq].instance;
+ u32 mask = BIT(idx & 0x1f);
void __iomem *reg = mtk_eint_get_offset(eint, d->hwirq,
eint->regs->mask_clr);
- eint->cur_mask[d->hwirq >> 5] |= mask;
+ eint->cur_mask[inst][idx >> 5] |= mask;
writel(mask, reg);
- if (eint->dual_edge[d->hwirq])
+ if (eint->pins[d->hwirq].dual_edge)
mtk_eint_flip_edge(eint, d->hwirq);
}
static unsigned int mtk_eint_get_mask(struct mtk_eint *eint,
unsigned int eint_num)
{
- unsigned int bit = BIT(eint_num % 32);
+ unsigned int bit = BIT(eint->pins[eint_num].index % 32);
void __iomem *reg = mtk_eint_get_offset(eint, eint_num,
eint->regs->mask);
return !!(readl(reg) & bit);
}
+static unsigned int mtk_eint_get_status(struct mtk_eint *eint,
+ unsigned int eint_num)
+{
+ unsigned int bit = BIT(eint->pins[eint_num].index % 32);
+ void __iomem *reg = mtk_eint_get_offset(eint, eint_num,
+ eint->regs->stat);
+
+ return !!(readl(reg) & bit);
+}
+
static void mtk_eint_ack(struct irq_data *d)
{
struct mtk_eint *eint = irq_data_get_irq_chip_data(d);
- u32 mask = BIT(d->hwirq & 0x1f);
+ u32 mask = BIT(eint->pins[d->hwirq].index & 0x1f);
void __iomem *reg = mtk_eint_get_offset(eint, d->hwirq,
eint->regs->ack);
@@ -174,7 +189,7 @@ static int mtk_eint_set_type(struct irq_data *d, unsigned int type)
{
struct mtk_eint *eint = irq_data_get_irq_chip_data(d);
bool masked;
- u32 mask = BIT(d->hwirq & 0x1f);
+ unsigned int mask = BIT(eint->pins[d->hwirq].index & 0x1f);
void __iomem *reg;
if (((type & IRQ_TYPE_EDGE_BOTH) && (type & IRQ_TYPE_LEVEL_MASK)) ||
@@ -186,9 +201,9 @@ static int mtk_eint_set_type(struct irq_data *d, unsigned int type)
}
if ((type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH)
- eint->dual_edge[d->hwirq] = 1;
+ eint->pins[d->hwirq].dual_edge = 1;
else
- eint->dual_edge[d->hwirq] = 0;
+ eint->pins[d->hwirq].dual_edge = 0;
if (!mtk_eint_get_mask(eint, d->hwirq)) {
mtk_eint_mask(d);
@@ -223,27 +238,32 @@ static int mtk_eint_set_type(struct irq_data *d, unsigned int type)
static int mtk_eint_irq_set_wake(struct irq_data *d, unsigned int on)
{
struct mtk_eint *eint = irq_data_get_irq_chip_data(d);
- int shift = d->hwirq & 0x1f;
- int reg = d->hwirq >> 5;
+ unsigned int idx = eint->pins[d->hwirq].index;
+ unsigned int inst = eint->pins[d->hwirq].instance;
+ unsigned int shift = idx & 0x1f;
+ unsigned int port = idx >> 5;
if (on)
- eint->wake_mask[reg] |= BIT(shift);
+ eint->wake_mask[inst][port] |= BIT(shift);
else
- eint->wake_mask[reg] &= ~BIT(shift);
+ eint->wake_mask[inst][port] &= ~BIT(shift);
return 0;
}
static void mtk_eint_chip_write_mask(const struct mtk_eint *eint,
- void __iomem *base, u32 *buf)
+ void __iomem *base, u32 **buf)
{
- int port;
+ int inst, port, port_num;
void __iomem *reg;
- for (port = 0; port < eint->hw->ports; port++) {
- reg = base + (port << 2);
- writel_relaxed(~buf[port], reg + eint->regs->mask_set);
- writel_relaxed(buf[port], reg + eint->regs->mask_clr);
+ for (inst = 0; inst < eint->nbase; inst++) {
+ port_num = DIV_ROUND_UP(eint->base_pin_num[inst], 32);
+ for (port = 0; port < port_num; port++) {
+ reg = eint->base[inst] + (port << 2);
+ writel_relaxed(~buf[inst][port], reg + eint->regs->mask_set);
+ writel_relaxed(buf[inst][port], reg + eint->regs->mask_clr);
+ }
}
}
@@ -303,15 +323,18 @@ static struct irq_chip mtk_eint_irq_chip = {
static unsigned int mtk_eint_hw_init(struct mtk_eint *eint)
{
- void __iomem *dom_en = eint->base + eint->regs->dom_en;
- void __iomem *mask_set = eint->base + eint->regs->mask_set;
- unsigned int i;
-
- for (i = 0; i < eint->hw->ap_num; i += 32) {
- writel(0xffffffff, dom_en);
- writel(0xffffffff, mask_set);
- dom_en += 4;
- mask_set += 4;
+ void __iomem *dom_reg, *mask_reg;
+ unsigned int i, j;
+
+ for (i = 0; i < eint->nbase; i++) {
+ dom_reg = eint->base[i] + eint->regs->dom_en;
+ mask_reg = eint->base[i] + eint->regs->mask_set;
+ for (j = 0; j < eint->base_pin_num[i]; j += 32) {
+ writel(0xffffffff, dom_reg);
+ writel(0xffffffff, mask_reg);
+ dom_reg += 4;
+ mask_reg += 4;
+ }
}
return 0;
@@ -322,14 +345,16 @@ mtk_eint_debounce_process(struct mtk_eint *eint, int index)
{
unsigned int rst, ctrl_offset;
unsigned int bit, dbnc;
+ unsigned int inst = eint->pins[index].instance;
+ unsigned int idx = eint->pins[index].index;
- ctrl_offset = (index / 4) * 4 + eint->regs->dbnc_ctrl;
- dbnc = readl(eint->base + ctrl_offset);
- bit = MTK_EINT_DBNC_SET_EN << ((index % 4) * 8);
+ ctrl_offset = (idx / 4) * 4 + eint->regs->dbnc_ctrl;
+ dbnc = readl(eint->base[inst] + ctrl_offset);
+ bit = MTK_EINT_DBNC_SET_EN << ((idx % 4) * 8);
if ((bit & dbnc) > 0) {
- ctrl_offset = (index / 4) * 4 + eint->regs->dbnc_set;
- rst = MTK_EINT_DBNC_RST_BIT << ((index % 4) * 8);
- writel(rst, eint->base + ctrl_offset);
+ ctrl_offset = (idx / 4) * 4 + eint->regs->dbnc_set;
+ rst = MTK_EINT_DBNC_RST_BIT << ((idx % 4) * 8);
+ writel(rst, eint->base[inst] + ctrl_offset);
}
}
@@ -337,20 +362,18 @@ static void mtk_eint_irq_handler(struct irq_desc *desc)
{
struct irq_chip *chip = irq_desc_get_chip(desc);
struct mtk_eint *eint = irq_desc_get_handler_data(desc);
- unsigned int status, eint_num;
- int offset, mask_offset, index;
- void __iomem *reg = mtk_eint_get_offset(eint, 0, eint->regs->stat);
+ unsigned int index, inst, idx, mask;
+ void __iomem *reg;
int dual_edge, start_level, curr_level;
chained_irq_enter(chip, desc);
- for (eint_num = 0; eint_num < eint->hw->ap_num; eint_num += 32,
- reg += 4) {
- status = readl(reg);
- while (status) {
- offset = __ffs(status);
- mask_offset = eint_num >> 5;
- index = eint_num + offset;
- status &= ~BIT(offset);
+ for (index = 0; index < eint->hw->ap_num; index++) {
+ inst = eint->pins[index].instance;
+ if (inst >= eint->nbase)
+ continue;
+ if (mtk_eint_get_status(eint, index)) {
+ idx = eint->pins[index].index;
+ mask = BIT(idx & 0x1f);
/*
* If we get an interrupt on pin that was only required
@@ -358,21 +381,22 @@ static void mtk_eint_irq_handler(struct irq_desc *desc)
* interrupt (as would mtk_eint_resume do anyway later
* in the resume sequence).
*/
- if (eint->wake_mask[mask_offset] & BIT(offset) &&
- !(eint->cur_mask[mask_offset] & BIT(offset))) {
- writel_relaxed(BIT(offset), reg -
- eint->regs->stat +
- eint->regs->mask_set);
+ if (eint->wake_mask[inst][idx >> 5] & mask &&
+ !(eint->cur_mask[inst][idx >> 5] & mask)) {
+ reg = mtk_eint_get_offset(eint, index,
+ eint->regs->mask_set);
+ writel_relaxed(mask, reg);
}
- dual_edge = eint->dual_edge[index];
+ dual_edge = eint->pins[index].dual_edge;
if (dual_edge) {
/*
* Clear soft-irq in case we raised it last
* time.
*/
- writel(BIT(offset), reg - eint->regs->stat +
- eint->regs->soft_clr);
+ reg = mtk_eint_get_offset(eint, index,
+ eint->regs->soft_clr);
+ writel(mask, reg);
start_level =
eint->gpio_xlate->get_gpio_state(eint->pctl,
@@ -388,13 +412,14 @@ static void mtk_eint_irq_handler(struct irq_desc *desc)
* If level changed, we might lost one edge
* interrupt, raised it through soft-irq.
*/
- if (start_level != curr_level)
- writel(BIT(offset), reg -
- eint->regs->stat +
- eint->regs->soft_set);
+ if (start_level != curr_level) {
+ reg = mtk_eint_get_offset(eint, index,
+ eint->regs->soft_set);
+ writel(mask, reg);
+ }
}
- if (index < eint->hw->db_cnt)
+ if (eint->pins[index].debounce)
mtk_eint_debounce_process(eint, index);
}
}
@@ -423,6 +448,8 @@ int mtk_eint_set_debounce(struct mtk_eint *eint, unsigned long eint_num,
int virq, eint_offset;
unsigned int set_offset, bit, clr_bit, clr_offset, rst, i, unmask,
dbnc;
+ unsigned int inst = eint->pins[eint_num].instance;
+ unsigned int idx = eint->pins[eint_num].index;
struct irq_data *d;
if (!eint->hw->db_time)
@@ -432,8 +459,8 @@ int mtk_eint_set_debounce(struct mtk_eint *eint, unsigned long eint_num,
eint_offset = (eint_num % 4) * 8;
d = irq_get_irq_data(virq);
- set_offset = (eint_num / 4) * 4 + eint->regs->dbnc_set;
- clr_offset = (eint_num / 4) * 4 + eint->regs->dbnc_clr;
+ set_offset = (idx / 4) * 4 + eint->regs->dbnc_set;
+ clr_offset = (idx / 4) * 4 + eint->regs->dbnc_clr;
if (!mtk_eint_can_en_debounce(eint, eint_num))
return -EINVAL;
@@ -454,12 +481,12 @@ int mtk_eint_set_debounce(struct mtk_eint *eint, unsigned long eint_num,
}
clr_bit = 0xff << eint_offset;
- writel(clr_bit, eint->base + clr_offset);
+ writel(clr_bit, eint->base[inst] + clr_offset);
bit = ((dbnc << MTK_EINT_DBNC_SET_DBNC_BITS) | MTK_EINT_DBNC_SET_EN) <<
eint_offset;
rst = MTK_EINT_DBNC_RST_BIT << eint_offset;
- writel(rst | bit, eint->base + set_offset);
+ writel(rst | bit, eint->base[inst] + set_offset);
/*
* Delay a while (more than 2T) to wait for hw debounce counter reset
@@ -487,32 +514,57 @@ EXPORT_SYMBOL_GPL(mtk_eint_find_irq);
int mtk_eint_do_init(struct mtk_eint *eint)
{
- int i;
+ 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)
eint->regs = &mtk_generic_eint_regs;
- eint->wake_mask = devm_kcalloc(eint->dev, eint->hw->ports,
- sizeof(*eint->wake_mask), GFP_KERNEL);
- if (!eint->wake_mask)
+ eint->base_pin_num = devm_kmalloc_array(eint->dev, eint->nbase, sizeof(u16),
+ GFP_KERNEL | __GFP_ZERO);
+ if (!eint->base_pin_num)
return -ENOMEM;
- eint->cur_mask = devm_kcalloc(eint->dev, eint->hw->ports,
- sizeof(*eint->cur_mask), GFP_KERNEL);
- if (!eint->cur_mask)
- return -ENOMEM;
+ 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)
+ goto err_pins;
+
+ eint->base_pin_num[0] = eint->hw->ap_num;
+ for (i = 0; i < eint->hw->ap_num; i++) {
+ eint->pins[i].instance = 0;
+ eint->pins[i].index = i;
+ 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->dual_edge = devm_kcalloc(eint->dev, eint->hw->ap_num,
- sizeof(int), GFP_KERNEL);
- if (!eint->dual_edge)
- return -ENOMEM;
+ eint->wake_mask = devm_kmalloc(eint->dev, eint->nbase * sizeof(u32 *), GFP_KERNEL);
+ if (!eint->wake_mask)
+ goto err_wake_mask;
+
+ eint->cur_mask = devm_kmalloc(eint->dev, eint->nbase * sizeof(u32 *), GFP_KERNEL);
+ if (!eint->cur_mask)
+ goto err_cur_mask;
+
+ for (i = 0; i < eint->nbase; i++) {
+ port = DIV_ROUND_UP(eint->base_pin_num[i], 32);
+ eint->wake_mask[i] = devm_kzalloc(eint->dev, port * sizeof(u32), GFP_KERNEL);
+ eint->cur_mask[i] = devm_kzalloc(eint->dev, port * sizeof(u32), GFP_KERNEL);
+ 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++)
@@ -523,6 +575,9 @@ int mtk_eint_do_init(struct mtk_eint *eint)
mtk_eint_hw_init(eint);
for (i = 0; i < eint->hw->ap_num; i++) {
+ if (eint->pins[i].instance >= eint->nbase)
+ continue;
+
int virq = irq_create_mapping(eint->domain, i);
irq_set_chip_and_handler(virq, &mtk_eint_irq_chip,
@@ -534,6 +589,23 @@ 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]);
+ }
+ devm_kfree(eint->dev, eint->cur_mask);
+err_cur_mask:
+ devm_kfree(eint->dev, eint->wake_mask);
+err_wake_mask:
+ if (eint->nbase == 1)
+ devm_kfree(eint->dev, eint->pins);
+err_pins:
+ devm_kfree(eint->dev, eint->base_pin_num);
+ return -ENOMEM;
}
EXPORT_SYMBOL_GPL(mtk_eint_do_init);
diff --git a/drivers/pinctrl/mediatek/mtk-eint.h b/drivers/pinctrl/mediatek/mtk-eint.h
index c1efdf02fb49..daaf0442b8b8 100644
--- a/drivers/pinctrl/mediatek/mtk-eint.h
+++ b/drivers/pinctrl/mediatek/mtk-eint.h
@@ -1,9 +1,11 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
- * Copyright (C) 2014-2018 MediaTek Inc.
+ * Copyright (C) 2014-2025 MediaTek Inc.
*
* Author: Maoguang Meng <maoguang.meng@mediatek.com>
* Sean Wang <sean.wang@mediatek.com>
+ * Hao Chang <ot_chhao.chang@mediatek.com>
+ * Qingliang Li <qingliang.li@mediatek.com>
*
*/
#ifndef __MTK_EINT_H
@@ -71,8 +73,8 @@ struct mtk_eint {
int irq;
int *dual_edge;
- u32 *wake_mask;
- u32 *cur_mask;
+ u32 **wake_mask;
+ u32 **cur_mask;
/* Used to fit into various EINT device */
const struct mtk_eint_hw *hw;
--
2.46.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v4 0/3] Add EINT support for multiple addresses
2025-02-25 14:07 [PATCH v4 0/3] Add EINT support for multiple addresses Hao Chang
` (2 preceding siblings ...)
2025-02-25 14:07 ` [PATCH v4 3/3] pinctrl: mediatek: adapt to EINT multi-segment addresses Hao Chang
@ 2025-03-14 9:58 ` Linus Walleij
2025-03-22 3:22 ` Chhao Chang (常浩)
3 siblings, 1 reply; 6+ messages in thread
From: Linus Walleij @ 2025-03-14 9:58 UTC (permalink / raw)
To: Hao Chang
Cc: Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
Wenbin Mei, Axe Yang, Qingliang Li, Hanks Chen, Chunhui Li,
linux-mediatek, linux-gpio, linux-kernel, linux-arm-kernel
Hi Hao,
thanks for your patches!
On Tue, Feb 25, 2025 at 3:07 PM Hao Chang <ot_chhao.chang@mediatek.com> wrote:
> This patch depends on
> [v3,2/2] pinctrl: mediatek: add mt8196 driver
> [v3,1/2] dt-bindings: pinctrl: mediatek: add support for mt8196
>
> Please also accept this patch together with [1]
> to avoid build and dt binding check error.
> [1]https://patchwork.kernel.org/project/linux-mediatek/list/?series=&submitter=215008&state=&q=v3&archive=&delegate=
Since the dependence series is not finished I can't apply these
patches either, do you want to send an independent version of these
patches so we merge them *first* since they seem finished?
Then the mt8196 series can rebase on your patches in v6.15-rc1
instead.
Just send a version based on v6.14-rc1 and I will apply it.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4 0/3] Add EINT support for multiple addresses
2025-03-14 9:58 ` [PATCH v4 0/3] Add EINT support for multiple addresses Linus Walleij
@ 2025-03-22 3:22 ` Chhao Chang (常浩)
0 siblings, 0 replies; 6+ messages in thread
From: Chhao Chang (常浩) @ 2025-03-22 3:22 UTC (permalink / raw)
To: linus.walleij@linaro.org
Cc: Chunhui Li (李春辉),
linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
Wenbin Mei (梅文彬), linux-gpio@vger.kernel.org,
sean.wang@kernel.org, Hanks Chen (陳彥廷),
matthias.bgg@gmail.com, Qingliang Li (黎晴亮),
linux-arm-kernel@lists.infradead.org, Axe Yang (杨磊),
AngeloGioacchino Del Regno
On Fri, 2025-03-14 at 10:58 +0100, Linus Walleij wrote:
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>
>
> Hi Hao,
>
> thanks for your patches!
>
> On Tue, Feb 25, 2025 at 3:07 PM Hao Chang <
> ot_chhao.chang@mediatek.com> wrote:
>
> > This patch depends on
> > [v3,2/2] pinctrl: mediatek: add mt8196 driver
> > [v3,1/2] dt-bindings: pinctrl: mediatek: add support for mt8196
> >
> > Please also accept this patch together with [1]
> > to avoid build and dt binding check error.
> > [1]
> > https://urldefense.com/v3/__https://patchwork.kernel.org/project/linux-mediatek/list/?series=&submitter=215008&state=&q=v3&archive=&delegate=__;!!CTRNKA9wMg0ARbw!gUMnwvZLiv7PLfBynupfezUYGOwSWFXcCubh-tJn4vobCnaiSRRXRgakWcQBdoQ8s0VNcBoQUpuFFhlLgtJb-OArDwfJKcQ$
>
> Since the dependence series is not finished I can't apply these
> patches either, do you want to send an independent version of these
> patches so we merge them *first* since they seem finished?
>
> Then the mt8196 series can rebase on your patches in v6.15-rc1
> instead.
>
> Just send a version based on v6.14-rc1 and I will apply it.
Thanks for your suggestion, I will fix this.
>
> Yours,
> Linus Walleij
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-03-22 3:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-25 14:07 [PATCH v4 0/3] Add EINT support for multiple addresses Hao Chang
2025-02-25 14:07 ` [PATCH v4 1/3] pinctrl: mediatek: add eint pins Hao Chang
2025-02-25 14:07 ` [PATCH v4 2/3] pinctrl: mediatek: modify the method of obtaining eint address Hao Chang
2025-02-25 14:07 ` [PATCH v4 3/3] pinctrl: mediatek: adapt to EINT multi-segment addresses Hao Chang
2025-03-14 9:58 ` [PATCH v4 0/3] Add EINT support for multiple addresses Linus Walleij
2025-03-22 3:22 ` Chhao Chang (常浩)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).