From nobody Thu Oct 2 09:22:11 2025 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A3B828643D; Thu, 18 Sep 2025 10:40:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758192033; cv=none; b=dDicdPVoQpVemCOXHtlJLnic81bQqjxgGBqhNDyzMAJEOGms/QxNGJ06uSIRwdxFYFOKCKMeBOaKYVp3xf3lNSi+5A7COS4Gw1FyzA7sZrBmFvcfQEt9hD+LUVuCHc44O3IXoFYf3sElexryCyVrpRI33V6DakLNSogoxjmyOUc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758192033; c=relaxed/simple; bh=cDnsLZ4FkikGplzQFI88HcrbzYEVL/zwv7o9gbMPj+k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ppbnolbr0OePUlF74r0t3toNwGkrPIbdRDc6sczpQuR4o5SCBhbH505pA8rwZWDeIf3J/86gYAfh7cN300/eFJ4Qr/TYorizw0PV5uoTKrdfXw3er09tchOxxHfOoPK2/38Ydyep34B55SIR/kbxFKxNIy/k+KlFzCiOhMcjDgs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=0AhQL20Q; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="0AhQL20Q" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 8C19E1A0ECF; Thu, 18 Sep 2025 10:40:29 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 60FD66062C; Thu, 18 Sep 2025 10:40:29 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id CDDDD102F1CE5; Thu, 18 Sep 2025 12:40:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1758192028; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=PWdWGwK6Jtb6d1BWxi9msgP+sjZMWAoPpdYFDAT4qEw=; b=0AhQL20QfLZPbZp1hUfr0oXs2/sUqGR5aTpMzIZ2fxoZoYtF36kxAjrJclh8E72QdHoU+n geEQ9bTYfRs35sd94XSNdINlzmIiL5WS5A0ES6d6ogOewVD5rSrc9tiTswsk9eboaBSH05 DPoWSePP+rLOqyuGS8VFCHxxje+iGZnMWdOTi+rfiRTgjXb0DQw3KX/tNQuopP1snKW/jg Iktu49vvpF+jU6JnRovrM62q4FJzMYN3i4B//ZAk/Aadd/bEJQNVI5PsLNbCbcrlNHkiEW Rtlpe+oW5DmSpxyan6yF22NXsJ5gq91DrWj5Md+5Dns9uphK5cP9fgox8O6JYA== From: "Herve Codina (Schneider Electric)" To: Thomas Gleixner , Wolfram Sang , Hoan Tran , Linus Walleij , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm , Saravana Kannan , Serge Semin , Herve Codina Cc: Phil Edworthy , linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Pascal Eberhard , Miquel Raynal , Thomas Petazzoni Subject: [PATCH v3 1/8] of/irq: Introduce for_each_of_imap_item Date: Thu, 18 Sep 2025 12:39:59 +0200 Message-ID: <20250918104009.94754-2-herve.codina@bootlin.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250918104009.94754-1-herve.codina@bootlin.com> References: <20250918104009.94754-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" for_each_of_imap_item is an iterator designed to help a driver to parse an interrupt-map property. Indeed some drivers need to know details about the interrupt mapping described in the device-tree in order to set internal registers accordingly. Signed-off-by: Herve Codina (Schneider Electric) Tested-by: Wolfram Sang --- drivers/of/irq.c | 70 ++++++++++++++++++++++++++++++++++++++++++ include/linux/of_irq.h | 41 ++++++++++++++++++++++++- 2 files changed, 110 insertions(+), 1 deletion(-) diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 74aaea61de13..0723ae4153a0 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -157,6 +157,76 @@ const __be32 *of_irq_parse_imap_parent(const __be32 *i= map, int len, struct of_ph return imap; } =20 +int of_imap_parser_init(struct of_imap_parser *parser, struct device_node = *node, + struct of_imap_item *item) +{ + int imaplen; + u32 tmp; + int ret; + + /* + * parent_offset is the offset where the parent part is starting. + * In other words, the offset where the parent interrupt controller + * phandle is present. + * + * Compute this offset (child #interrupt-cells + child #address-cells) + */ + parser->parent_offset =3D of_bus_n_addr_cells(node); + + ret =3D of_property_read_u32(node, "#interrupt-cells", &tmp); + if (ret) + return ret; + + parser->parent_offset +=3D tmp; + + if (WARN(parser->parent_offset > ARRAY_SIZE(item->child_imap), + "child part size =3D %u, cannot fit in array of %zu items", + parser->parent_offset, ARRAY_SIZE(item->child_imap))) + return -EINVAL; + + parser->imap =3D of_get_property(node, "interrupt-map", &imaplen); + if (!parser->imap) + return -ENOENT; + + imaplen /=3D sizeof(*parser->imap); + parser->imap_end =3D parser->imap + imaplen; + + memset(item, 0, sizeof(*item)); + item->child_imap_count =3D parser->parent_offset; + + return 0; +} +EXPORT_SYMBOL_GPL(of_imap_parser_init); + +struct of_imap_item *of_imap_parser_one(struct of_imap_parser *parser, + struct of_imap_item *item) +{ + const __be32 *imap_parent, *imap_next; + int i; + + /* Release previously get parent node */ + of_node_put(item->parent_args.np); + + if (parser->imap + parser->parent_offset + 1 >=3D parser->imap_end) + return NULL; + + imap_parent =3D parser->imap + parser->parent_offset; + + imap_next =3D of_irq_parse_imap_parent(imap_parent, + parser->imap_end - imap_parent, + &item->parent_args); + if (!imap_next) + return NULL; + + for (i =3D 0; i < parser->parent_offset; i++) + item->child_imap[i] =3D be32_to_cpu(*(parser->imap + i)); + + parser->imap =3D imap_next; + + return item; +} +EXPORT_SYMBOL_GPL(of_imap_parser_one); + /** * of_irq_parse_raw - Low level interrupt tree parsing * @addr: address specifier (start of "reg" property of the device) in be3= 2 format diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h index a480063c9cb1..65f2c97147de 100644 --- a/include/linux/of_irq.h +++ b/include/linux/of_irq.h @@ -11,6 +11,30 @@ =20 typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *= ); =20 +struct of_imap_parser { + struct device_node *node; + const __be32 *imap; + const __be32 *imap_end; + u32 parent_offset; +}; + +struct of_imap_item { + struct of_phandle_args parent_args; + u32 child_imap_count; + u32 child_imap[16]; /* Arbitrary size. + * Should be #address-cells + #interrupt-cells but + * avoid using allocation and so, expect that 16 + * should be enough + */ +}; + +/* + * If the iterator is exited prematurely (break, goto, return) of_node_put= () has + * to be called on item.parent_args.np + */ +#define for_each_of_imap_item(parser, item) \ + for (; of_imap_parser_one(parser, item);) + /* * Workarounds only applied to 32bit powermac machines */ @@ -47,6 +71,11 @@ extern int of_irq_get_byname(struct device_node *dev, co= nst char *name); extern int of_irq_to_resource_table(struct device_node *dev, struct resource *res, int nr_irqs); extern struct device_node *of_irq_find_parent(struct device_node *child); +extern int of_imap_parser_init(struct of_imap_parser *parser, + struct device_node *node, + struct of_imap_item *item); +extern struct of_imap_item *of_imap_parser_one(struct of_imap_parser *pars= er, + struct of_imap_item *item); extern struct irq_domain *of_msi_get_domain(struct device *dev, const struct device_node *np, enum irq_domain_bus_token token); @@ -86,7 +115,17 @@ static inline void *of_irq_find_parent(struct device_no= de *child) { return NULL; } - +static inline int of_imap_parser_init(struct of_imap_parser *parser, + struct device_node *node, + struct of_imap_item *item) +{ + return -ENOSYS; +} +static inline struct of_imap_item *of_imap_parser_one(struct of_imap_parse= r *parser, + struct of_imap_item *item) +{ + return NULL; +} static inline struct irq_domain *of_msi_get_domain(struct device *dev, struct device_node *np, enum irq_domain_bus_token token) --=20 2.51.0 From nobody Thu Oct 2 09:22:11 2025 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 991C6283FD0 for ; Thu, 18 Sep 2025 10:40:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758192035; cv=none; b=Wir88vblUIU8R30Db1OojYCSDMdv1NCaVwzPI0i+M4d4pZZ5cbi6l2z32yzTuDmS+iqA4zfEOtaZBvhdN8XZbm/43Ax+KujCBD/s7ETI5o65aKknciaqkDojBAY5on3tw1+gm5Fi9ox2UpyvKhkStn5V47eIm21n/OD3QUzDkac= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758192035; c=relaxed/simple; bh=WPoO/J6qy3ZxqCU4yUEKN3EvIZusmouMlbOsqeF8Edg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lgb0qv+1lTaZ6ozuwXwnmPTyWKSDc8QOgUHQDJXZgSXJDZWt1990GGfZ1qcy76dkNBRD3AvAYUKOqfKzpBAQhyY/f7WweM89Cm5e4y+FfXzClhUg9BQ3iI23EVca6hITZYtE0O+34n7RzJwkgXpCQUJaJQWdFd7e3TIHdwfQj+s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=L4W9GFIs; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="L4W9GFIs" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 2ACAB4E40D0B; Thu, 18 Sep 2025 10:40:32 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id F37756062C; Thu, 18 Sep 2025 10:40:31 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id E6832102F1CFE; Thu, 18 Sep 2025 12:40:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1758192030; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=DEVAHFx1j54RT/HtKdiavyIr4g1EULYBfCovF+2WZY0=; b=L4W9GFIs/5vVyuNluBs0xaASTNoTtI5n21RtuTznxRvP3SRuTZhgsHFbIH8ikSNpy3zk+x yqvML/EzjbVToESPCS6JUSr/pyp95XnWXB4/+xmmhHKcnbHLewHiJlkTskljYI5BVXxEix HKwUqpbjUMniglYUaqNN0Lg7f123fPPmWIUiK0vhNnRk3+q09jbR5K1ott2d8x3EHDBKuU Id7iOGC7AN1KSKwcEe9NLbEHMwhN670APS44/qSJVPIw/5JDHSoxVkgKJoEW8tDA57JAnL MnraeV3sM/ENSZE0yJgIECzYPlJzvlm5Hmdoxjx3+39m+wLI9EPvsrxtWso/2A== From: "Herve Codina (Schneider Electric)" To: Thomas Gleixner , Wolfram Sang , Hoan Tran , Linus Walleij , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm , Saravana Kannan , Serge Semin , Herve Codina Cc: Phil Edworthy , linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Pascal Eberhard , Miquel Raynal , Thomas Petazzoni Subject: [PATCH v3 2/8] of: unittest: Add a test case for for_each_of_imap_item iterator Date: Thu, 18 Sep 2025 12:40:00 +0200 Message-ID: <20250918104009.94754-3-herve.codina@bootlin.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250918104009.94754-1-herve.codina@bootlin.com> References: <20250918104009.94754-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" Recently for_each_of_imap_item iterator has been introduce to help drivers in parsing the interrupt-map property. Add a test case for this iterator. Signed-off-by: Herve Codina (Schneider Electric) Tested-by: Wolfram Sang --- .../of/unittest-data/tests-interrupts.dtsi | 9 ++ drivers/of/unittest.c | 116 ++++++++++++++++++ 2 files changed, 125 insertions(+) diff --git a/drivers/of/unittest-data/tests-interrupts.dtsi b/drivers/of/un= ittest-data/tests-interrupts.dtsi index 4ccb54f91c30..974f888c9b15 100644 --- a/drivers/of/unittest-data/tests-interrupts.dtsi +++ b/drivers/of/unittest-data/tests-interrupts.dtsi @@ -50,6 +50,15 @@ test_intmap1: intmap1 { interrupt-map =3D <0x5000 1 2 &test_intc0 15>; }; =20 + intmap2 { + #interrupt-cells =3D <2>; + #address-cells =3D <0>; + interrupt-map =3D <1 11 &test_intc0 100>, + <2 22 &test_intc1 200 201 202>, + <3 33 &test_intc2 300 301>, + <4 44 &test_intc2 400 401>; + }; + test_intc_intmap0: intc-intmap0 { #interrupt-cells =3D <1>; #address-cells =3D <1>; diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index e3503ec20f6c..be4d9571f16e 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -1654,6 +1654,121 @@ static void __init of_unittest_parse_interrupts_ext= ended(void) of_node_put(np); } =20 +struct of_unittest_expected_imap_item { + u32 child_imap_count; + u32 child_imap[2]; + const char *parent_path; + int parent_args_count; + u32 parent_args[3]; +}; + +static const struct of_unittest_expected_imap_item of_unittest_expected_im= ap_items[] =3D { + { + .child_imap_count =3D 2, + .child_imap =3D {1, 11}, + .parent_path =3D "/testcase-data/interrupts/intc0", + .parent_args_count =3D 1, + .parent_args =3D {100}, + }, { + .child_imap_count =3D 2, + .child_imap =3D {2, 22}, + .parent_path =3D "/testcase-data/interrupts/intc1", + .parent_args_count =3D 3, + .parent_args =3D {200, 201, 202}, + }, { + .child_imap_count =3D 2, + .child_imap =3D {3, 33}, + .parent_path =3D "/testcase-data/interrupts/intc2", + .parent_args_count =3D 2, + .parent_args =3D {300, 301}, + }, { + .child_imap_count =3D 2, + .child_imap =3D {4, 44}, + .parent_path =3D "/testcase-data/interrupts/intc2", + .parent_args_count =3D 2, + .parent_args =3D {400, 401}, + } +}; + +static void __init of_unittest_parse_interrupt_map(void) +{ + const struct of_unittest_expected_imap_item *expected_item; + struct device_node *imap_np, *expected_parent_np; + struct of_imap_parser imap_parser; + struct of_imap_item imap_item; + int count, ret, i; + + if (of_irq_workarounds & (OF_IMAP_NO_PHANDLE | OF_IMAP_OLDWORLD_MAC)) + return; + + imap_np =3D of_find_node_by_path("/testcase-data/interrupts/intmap2"); + if (!imap_np) { + pr_err("missing testcase data\n"); + return; + } + + ret =3D of_imap_parser_init(&imap_parser, imap_np, &imap_item); + if (unittest(!ret, "of_imap_parser_init(%pOF) returned error %d\n", + imap_np, ret)) + goto end; + + expected_item =3D of_unittest_expected_imap_items; + count =3D 0; + + for_each_of_imap_item(&imap_parser, &imap_item) { + if (unittest(count < ARRAY_SIZE(of_unittest_expected_imap_items), + "imap item number %d not expected. Max number %zu\n", + count, ARRAY_SIZE(of_unittest_expected_imap_items) - 1)) { + of_node_put(imap_item.parent_args.np); + goto end; + } + + expected_parent_np =3D of_find_node_by_path(expected_item->parent_path); + if (unittest(expected_parent_np, + "missing dependent testcase data (%s)\n", + expected_item->parent_path)) { + of_node_put(imap_item.parent_args.np); + goto end; + } + + unittest(imap_item.child_imap_count =3D=3D expected_item->child_imap_cou= nt, + "imap[%d] child_imap_count =3D %u, expected %u\n", + count, imap_item.child_imap_count, + expected_item->child_imap_count); + + for (i =3D 0; i < expected_item->child_imap_count; i++) + unittest(imap_item.child_imap[i] =3D=3D expected_item->child_imap[i], + "imap[%d] child_imap[%d] =3D %u, expected %u\n", + count, i, imap_item.child_imap[i], + expected_item->child_imap[i]); + + unittest(imap_item.parent_args.np =3D=3D expected_parent_np, + "imap[%d] parent np =3D %pOF, expected %pOF\n", + count, imap_item.parent_args.np, expected_parent_np); + + unittest(imap_item.parent_args.args_count =3D=3D expected_item->parent_a= rgs_count, + "imap[%d] parent param_count =3D %d, expected %d\n", + count, imap_item.parent_args.args_count, + expected_item->parent_args_count); + + for (i =3D 0; i < expected_item->parent_args_count; i++) + unittest(imap_item.parent_args.args[i] =3D=3D expected_item->parent_arg= s[i], + "imap[%d] parent param[%d] =3D %u, expected %u\n", + count, i, imap_item.parent_args.args[i], + expected_item->parent_args[i]); + + of_node_put(expected_parent_np); + count++; + expected_item++; + } + + unittest(count =3D=3D ARRAY_SIZE(of_unittest_expected_imap_items), + "Missing items. %d parsed, expected %zu\n", + count, ARRAY_SIZE(of_unittest_expected_imap_items)); +end: + of_node_put(imap_np); +} + #if IS_ENABLED(CONFIG_OF_DYNAMIC) static void __init of_unittest_irq_refcount(void) { @@ -4394,6 +4509,7 @@ static int __init of_unittest(void) of_unittest_changeset_prop(); of_unittest_parse_interrupts(); of_unittest_parse_interrupts_extended(); + of_unittest_parse_interrupt_map(); of_unittest_irq_refcount(); of_unittest_dma_get_max_cpu_address(); of_unittest_parse_dma_ranges(); --=20 2.51.0 From nobody Thu Oct 2 09:22:11 2025 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F37CE2F9DA5; Thu, 18 Sep 2025 10:40:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758192038; cv=none; b=oaft9mDl43oaqfP5Mk44oloqrwBGd6VvuVueiA7bwPA3wM25I/FuTYOhWGX6pG6MBthAFJHTLOFf4dFxvOl67QrvTI+dzL1NaNXKqG4tEPeJ3BKSlQO7/VC38J/ZEneZnazX1HmRya3TwhxIlnIRhX7OE3E7RS02PwqXo4S2XsA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758192038; c=relaxed/simple; bh=wKTOuqBfnalEmfN7yoZWb6HUSWjmCULlR5vNporkClE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ARJ3UEkwCFth/WekLDSA3M9jcWSbodMajZ+eNUl097RDicERkq78GEo5N6xx7WNnPX+DZbENW7LE3J+7CLONvB431CYcCiR+eKLrLlwzaz9uSfZOu6IpZnSGxJ05A6tnXAGvrZt7aaNRzUlAZ/fwhqQtK7rYNgugAEXbr2xpFS4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=qivI2scR; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="qivI2scR" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 511244E40D0C; Thu, 18 Sep 2025 10:40:34 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 265DF6062C; Thu, 18 Sep 2025 10:40:34 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 9F59C102F1CE5; Thu, 18 Sep 2025 12:40:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1758192033; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=QBlfnPJwGIXoUklEq6xYhFHnSO32edjs9JLjQGY9LrA=; b=qivI2scRDBJFEK5DDAVU3ozIIkeDuNXhVlTKLUcJ9fxapRg9jbyFwiEHs3OnAyAcsYi1la 6HgZt/5okulZhrt4HLQO6WPUIe2BXCfpPxehscvg/c4B/78dZ4bFdkLSUUIbPQ1O1d68km Lqi7GRnCEy+QuMnmqO0bX4rpqwsYH3TTCAs2wmkWt+muSTezmGjGGVmX9+35v9XRABNJ4t 6zwhpSiX0okTPn3Ypeab3qTW1H3aXSkjfLVIbQkiGjWxHsZVMX4CEdxbZ1iZZko1veppXC +4Fv8J1bwkKgKzJz05dD7bsuHsy1G4ZdPGL10mMjHITlGJwL1V+P6tvuwvJG8Q== From: "Herve Codina (Schneider Electric)" To: Thomas Gleixner , Wolfram Sang , Hoan Tran , Linus Walleij , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm , Saravana Kannan , Serge Semin , Herve Codina Cc: Phil Edworthy , linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Pascal Eberhard , Miquel Raynal , Thomas Petazzoni Subject: [PATCH v3 3/8] irqchip/ls-extirq: Use for_each_of_imap_item iterator Date: Thu, 18 Sep 2025 12:40:01 +0200 Message-ID: <20250918104009.94754-4-herve.codina@bootlin.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250918104009.94754-1-herve.codina@bootlin.com> References: <20250918104009.94754-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The ls-extirq driver parses the interrupt-map property. It does it using open code. Recently for_each_of_imap_item iterator has been introduce to help drivers in this parsing. Convert the ls-extirq driver to use the for_each_of_imap_item iterator instead of open code. Signed-off-by: Herve Codina (Schneider Electric) Tested-by: Wolfram Sang --- drivers/irqchip/irq-ls-extirq.c | 47 ++++++++++++--------------------- 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/drivers/irqchip/irq-ls-extirq.c b/drivers/irqchip/irq-ls-extir= q.c index 50a7b38381b9..ed8755777349 100644 --- a/drivers/irqchip/irq-ls-extirq.c +++ b/drivers/irqchip/irq-ls-extirq.c @@ -125,45 +125,32 @@ static const struct irq_domain_ops extirq_domain_ops = =3D { static int ls_extirq_parse_map(struct ls_extirq_data *priv, struct device_node *node) { - const __be32 *map; - u32 mapsize; + struct of_imap_parser imap_parser; + struct of_imap_item imap_item; int ret; =20 - map =3D of_get_property(node, "interrupt-map", &mapsize); - if (!map) - return -ENOENT; - if (mapsize % sizeof(*map)) - return -EINVAL; - mapsize /=3D sizeof(*map); + ret =3D of_imap_parser_init(&imap_parser, node, &imap_item); + if (ret) + return ret; =20 - while (mapsize) { + for_each_of_imap_item(&imap_parser, &imap_item) { struct device_node *ipar; - u32 hwirq, intsize, j; + u32 hwirq; + int i; =20 - if (mapsize < 3) - return -EINVAL; - hwirq =3D be32_to_cpup(map); - if (hwirq >=3D MAXIRQ) + hwirq =3D imap_item.child_imap[0]; + if (hwirq >=3D MAXIRQ) { + of_node_put(imap_item.parent_args.np); return -EINVAL; + } priv->nirq =3D max(priv->nirq, hwirq + 1); =20 - ipar =3D of_find_node_by_phandle(be32_to_cpup(map + 2)); - map +=3D 3; - mapsize -=3D 3; - if (!ipar) - return -EINVAL; - priv->map[hwirq].fwnode =3D &ipar->fwnode; - ret =3D of_property_read_u32(ipar, "#interrupt-cells", &intsize); - if (ret) - return ret; - - if (intsize > mapsize) - return -EINVAL; + ipar =3D of_node_get(imap_item.parent_args.np); + priv->map[hwirq].fwnode =3D of_fwnode_handle(ipar); =20 - priv->map[hwirq].param_count =3D intsize; - for (j =3D 0; j < intsize; ++j) - priv->map[hwirq].param[j] =3D be32_to_cpup(map++); - mapsize -=3D intsize; + priv->map[hwirq].param_count =3D imap_item.parent_args.args_count; + for (i =3D 0; i < priv->map[hwirq].param_count; i++) + priv->map[hwirq].param[i] =3D imap_item.parent_args.args[i]; } return 0; } --=20 2.51.0 From nobody Thu Oct 2 09:22:11 2025 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B48372FBDF3; Thu, 18 Sep 2025 10:40:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758192040; cv=none; b=Wm/5DIyk6w15uLDtDwlbzv7hzSM/eej5WsDR4epD+vLiQmw9+xTZht3VzjoCrKwBgMkzc3MurnCKsl30PRIw1S0iCq/cy5JamNHHdq2XSP7P0aBiGuCa3/ak+dxtSI9DVtFpHdyyUgxqk2d8Su76VTd6ByAh1JZNOvB7dFWPaGQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758192040; c=relaxed/simple; bh=piDyw/JBKCG/8fXN+QSQlF/zxGTFUxOsg8dUrAeAvbo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ep9Dro5em3dkyjeK6+bh1SjIxb9sMn3rTg/h+lSW8pxY1qeSlxAmudymkRxY6OiVBCHSpR44lfSmkrybW8RPw/kbI6e6IZAsFq4vE+PUBobB2HnlInRwse+qTrzy02/DDti+m1BkygqCz2eWl+rus5OSJpaYcxYFVGmL9bWasUo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=Is1h7xYC; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Is1h7xYC" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 93BD3C00097; Thu, 18 Sep 2025 10:40:19 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 2F1246062C; Thu, 18 Sep 2025 10:40:36 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 95E80102F1CD5; Thu, 18 Sep 2025 12:40:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1758192035; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=NsWsJA6GhKlZSDm7Rvg/BA2HitF/XF0eT4AqsM0ba84=; b=Is1h7xYCBN7h5ryzVVsd7Ppp9vCsLhiUd2lUwuYPavcHV81hn0N9DShuUTR5ETJeoMMXKm DlONEmNmR+XnTLzjHupXP6tfmWGnyYusCrdZ36uD5DVc6yB0j/sadX8XjpOGDI2CzM1TGY rCUtjsvsfs9WPEfy/Aho8y0yDpaDqTWg6Ov+rLu+Ey38H3Rhx6vBmHRmu90daAFRCBDYOf xUPt/Km6VZzcxkDOLls7Po+/Aj8JK2RxQPuz1qrhTQ9e7mQvun+Q+1AKm4BiJAw7yuD7tK izYtaGR1z6EP7GABTSY7CO38+UYSvo6a7x2KClosCAdaROq4cozZo21SustfMQ== From: "Herve Codina (Schneider Electric)" To: Thomas Gleixner , Wolfram Sang , Hoan Tran , Linus Walleij , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm , Saravana Kannan , Serge Semin , Herve Codina Cc: Phil Edworthy , linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Pascal Eberhard , Miquel Raynal , Thomas Petazzoni Subject: [PATCH v3 4/8] irqchip/renesas-rza1: Use for_each_of_imap_item iterator Date: Thu, 18 Sep 2025 12:40:02 +0200 Message-ID: <20250918104009.94754-5-herve.codina@bootlin.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250918104009.94754-1-herve.codina@bootlin.com> References: <20250918104009.94754-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The renesas-rza1 driver parses the interrupt-map property. It does it using open code. Recently for_each_of_imap_item iterator has been introduce to help drivers in this parsing. Convert the renesas-rza1 driver to use the for_each_of_imap_item iterator instead of open code. Signed-off-by: Herve Codina (Schneider Electric) Tested-by: Wolfram Sang --- drivers/irqchip/irq-renesas-rza1.c | 43 +++++++++++------------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/drivers/irqchip/irq-renesas-rza1.c b/drivers/irqchip/irq-renes= as-rza1.c index a697eb55ac90..789196b71656 100644 --- a/drivers/irqchip/irq-renesas-rza1.c +++ b/drivers/irqchip/irq-renesas-rza1.c @@ -142,46 +142,35 @@ static const struct irq_domain_ops rza1_irqc_domain_o= ps =3D { static int rza1_irqc_parse_map(struct rza1_irqc_priv *priv, struct device_node *gic_node) { - unsigned int imaplen, i, j, ret; + struct of_imap_parser imap_parser; struct device *dev =3D priv->dev; + struct of_imap_item imap_item; struct device_node *ipar; - const __be32 *imap; - u32 intsize; + int j, ret; + u32 i =3D 0; =20 - imap =3D of_get_property(dev->of_node, "interrupt-map", &imaplen); - if (!imap) - return -EINVAL; - - for (i =3D 0; i < IRQC_NUM_IRQ; i++) { - if (imaplen < 3) - return -EINVAL; + ret =3D of_imap_parser_init(&imap_parser, dev->of_node, &imap_item); + if (ret) + return ret; =20 + for_each_of_imap_item(&imap_parser, &imap_item) { /* Check interrupt number, ignore sense */ - if (be32_to_cpup(imap) !=3D i) + if (imap_item.child_imap[0] !=3D i) { + of_node_put(imap_item.parent_args.np); return -EINVAL; + } =20 - ipar =3D of_find_node_by_phandle(be32_to_cpup(imap + 2)); + ipar =3D imap_item.parent_args.np; if (ipar !=3D gic_node) { of_node_put(ipar); return -EINVAL; } =20 - imap +=3D 3; - imaplen -=3D 3; - - ret =3D of_property_read_u32(ipar, "#interrupt-cells", &intsize); - of_node_put(ipar); - if (ret) - return ret; - - if (imaplen < intsize) - return -EINVAL; - - priv->map[i].args_count =3D intsize; - for (j =3D 0; j < intsize; j++) - priv->map[i].args[j] =3D be32_to_cpup(imap++); + priv->map[i].args_count =3D imap_item.parent_args.args_count; + for (j =3D 0; j < priv->map[i].args_count; j++) + priv->map[i].args[j] =3D imap_item.parent_args.args[j]; =20 - imaplen -=3D intsize; + i++; } =20 return 0; --=20 2.51.0 From nobody Thu Oct 2 09:22:11 2025 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EFF682FDC24; Thu, 18 Sep 2025 10:40:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758192043; cv=none; b=qCTokDCkrrStehrgaSUKwxu6LQ29HpqOqnG/QQNnLgV0v5pAPRTejr9TvnqzOpurTbY4H+JMB4HsJe5kS+429Ukve0lBBFiddpHQ6HBKspCjxoYLKqkEI0tgVd9+GNvIWmV7u3ZMpBpCPUzCmfupUWH2oxI93AU7H6mrgDAsyCE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758192043; c=relaxed/simple; bh=mYnLnoggH5C112eT9SpykwV2oYxC50Z4VtB47FiCOz4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F3Ri4u8DN2XJoePRm34T4JilmYV+oYQkFIhD32WeoAhObhx0k71kzFmolmw9Jn80eN/Rxnn1DsyNAm3ENX8JKrB5uiVZ0kXnK0YX02MJw5ZzN9RAW9rz2b5jHORz9xlIfd0z/5iH34OHsXRbMAyKjNtDEf45G9kPL65xBHeUU4A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=fAZlh042; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="fAZlh042" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 9CD584E40D09; Thu, 18 Sep 2025 10:40:38 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 736D26062C; Thu, 18 Sep 2025 10:40:38 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id C9B73102F1D03; Thu, 18 Sep 2025 12:40:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1758192037; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=LRs+ZbxoZ3cLLVekDsoFCzVnx6IirV9YTJ378KbO7+s=; b=fAZlh042JZKWn9yYVZANBi75pL9f4FyAq0Za2H2oiU6jEtL41HsiRdQRC0Apg5oFxkwJA0 8tpFS2m3uSC4UHdaFsl+rngdoohCh+YCNWh3Ta3k2KbOxSwihPbLUqjKbD6LtGyYeZJQ8R LjPF0ljgtI1INrFELXqRyaMFei2tb+I198mcWoKxZzg3OsWHaZsaIfBBZQ0bbf7bhk+Mmp oaOs2fiGco+A6hAmTdOO3JjbwbBcp6ZXCppD+eRkpkRcPd1WlJCGyD2NbjnaBiBhIlnd7x pWY9PPIpvwKHK+d2oDjKw05TCZOBt+DhTDxJ8F06RTnEZwLYdA8c0gLP20qhCA== From: "Herve Codina (Schneider Electric)" To: Thomas Gleixner , Wolfram Sang , Hoan Tran , Linus Walleij , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm , Saravana Kannan , Serge Semin , Herve Codina Cc: Phil Edworthy , linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Pascal Eberhard , Miquel Raynal , Thomas Petazzoni Subject: [PATCH v3 5/8] ARM: dts: r9a06g032: Add GPIO controllers Date: Thu, 18 Sep 2025 12:40:03 +0200 Message-ID: <20250918104009.94754-6-herve.codina@bootlin.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250918104009.94754-1-herve.codina@bootlin.com> References: <20250918104009.94754-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" Add GPIO controllers (Synosys DesignWare IPs) available in the r9a06g032 (RZ/N1D) SoC. Signed-off-by: Herve Codina (Schneider Electric) Reviewed-by: Wolfram Sang Tested-by: Wolfram Sang Reviewed-by: Bartosz Golaszewski --- arch/arm/boot/dts/renesas/r9a06g032.dtsi | 121 +++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/arch/arm/boot/dts/renesas/r9a06g032.dtsi b/arch/arm/boot/dts/r= enesas/r9a06g032.dtsi index 13a60656b044..da977cdd8487 100644 --- a/arch/arm/boot/dts/renesas/r9a06g032.dtsi +++ b/arch/arm/boot/dts/renesas/r9a06g032.dtsi @@ -499,6 +499,127 @@ gic: interrupt-controller@44101000 { ; }; =20 + /* + * The GPIO mapping to the corresponding pins is not obvious. + * See the hardware documentation for details. + */ + gpio0: gpio@5000b000 { + compatible =3D "snps,dw-apb-gpio"; + reg =3D <0x5000b000 0x80>; + #address-cells =3D <1>; + #size-cells =3D <0>; + clocks =3D <&sysctrl R9A06G032_HCLK_GPIO0>; + clock-names =3D "bus"; + status =3D "disabled"; + + /* GPIO0a[0] connected to pin GPIO0 */ + /* GPIO0a[1..2] connected to pins GPIO3..4 */ + /* GPIO0a[3..4] connected to pins GPIO9..10 */ + /* GPIO0a[5] connected to pin GPIO12 */ + /* GPIO0a[6..7] connected to pins GPIO15..16 */ + /* GPIO0a[8..9] connected to pins GPIO21..22 */ + /* GPIO0a[10] connected to pin GPIO24 */ + /* GPIO0a[11..12] connected to pins GPIO27..28 */ + /* GPIO0a[13..14] connected to pins GPIO33..34 */ + /* GPIO0a[15] connected to pin GPIO36 */ + /* GPIO0a[16..17] connected to pins GPIO39..40 */ + /* GPIO0a[18..19] connected to pins GPIO45..46 */ + /* GPIO0a[20] connected to pin GPIO48 */ + /* GPIO0a[21..22] connected to pins GPIO51..52 */ + /* GPIO0a[23..24] connected to pins GPIO57..58 */ + /* GPIO0a[25..31] connected to pins GPIO62..68 */ + gpio0a: gpio-port@0 { + compatible =3D "snps,dw-apb-gpio-port"; + gpio-controller; + #gpio-cells =3D <2>; + snps,nr-gpios =3D <32>; + reg =3D <0>; + }; + + /* GPIO0b[0..1] connected to pins GPIO1..2 */ + /* GPIO0b[2..5] connected to pins GPIO5..8 */ + /* GPIO0b[6] connected to pin GPIO11 */ + /* GPIO0b[7..8] connected to pins GPIO13..14 */ + /* GPIO0b[9..12] connected to pins GPIO17..20 */ + /* GPIO0b[13] connected to pin GPIO23 */ + /* GPIO0b[14..15] connected to pins GPIO25..26 */ + /* GPIO0b[16..19] connected to pins GPIO29..32 */ + /* GPIO0b[20] connected to pin GPIO35 */ + /* GPIO0b[21..22] connected to pins GPIO37..38 */ + /* GPIO0b[23..26] connected to pins GPIO41..44 */ + /* GPIO0b[27] connected to pin GPIO47 */ + /* GPIO0b[28..29] connected to pins GPIO49..50 */ + /* GPIO0b[30..31] connected to pins GPIO53..54 */ + gpio0b: gpio-port@1 { + compatible =3D "snps,dw-apb-gpio-port"; + gpio-controller; + #gpio-cells =3D <2>; + snps,nr-gpios =3D <32>; + reg =3D <1>; + }; + }; + + gpio1: gpio@5000c000 { + compatible =3D "snps,dw-apb-gpio"; + reg =3D <0x5000c000 0x80>; + #address-cells =3D <1>; + #size-cells =3D <0>; + clocks =3D <&sysctrl R9A06G032_HCLK_GPIO1>; + clock-names =3D "bus"; + status =3D "disabled"; + + /* GPIO1a[0..4] connected to pins GPIO69..73 */ + /* GPIO1a[5..31] connected to pins GPIO95..121 */ + gpio1a: gpio-port@0 { + compatible =3D "snps,dw-apb-gpio-port"; + gpio-controller; + #gpio-cells =3D <2>; + snps,nr-gpios =3D <32>; + reg =3D <0>; + }; + + /* GPIO1b[0..1] connected to pins GPIO55..56 */ + /* GPIO1b[2..4] connected to pins GPIO59..61 */ + /* GPIO1b[5..25] connected to pins GPIO74..94 */ + /* GPIO1b[26..31] connected to pins GPIO150..155 */ + gpio1b: gpio-port@1 { + compatible =3D "snps,dw-apb-gpio-port"; + gpio-controller; + #gpio-cells =3D <2>; + snps,nr-gpios =3D <32>; + reg =3D <1>; + }; + }; + + gpio2: gpio@5000d000 { + compatible =3D "snps,dw-apb-gpio"; + reg =3D <0x5000d000 0x80>; + #address-cells =3D <1>; + #size-cells =3D <0>; + clocks =3D <&sysctrl R9A06G032_HCLK_GPIO2>; + clock-names =3D "bus"; + status =3D "disabled"; + + /* GPIO2a[0..27] connected to pins GPIO122..149 */ + /* GPIO2a[28..31] connected to pins GPIO156..159 */ + gpio2a: gpio-port@0 { + compatible =3D "snps,dw-apb-gpio-port"; + gpio-controller; + #gpio-cells =3D <2>; + snps,nr-gpios =3D <32>; + reg =3D <0>; + }; + + /* GPIO2b[0..9] connected to pins GPIO160..169 */ + gpio2b: gpio-port@1 { + compatible =3D "snps,dw-apb-gpio-port"; + gpio-controller; + #gpio-cells =3D <2>; + snps,nr-gpios =3D <10>; + reg =3D <1>; + }; + }; + can0: can@52104000 { compatible =3D "renesas,r9a06g032-sja1000", "renesas,rzn1-sja1000"; reg =3D <0x52104000 0x800>; --=20 2.51.0 From nobody Thu Oct 2 09:22:11 2025 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48A3B2FF65D for ; Thu, 18 Sep 2025 10:40:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758192044; cv=none; b=ftMXNArvDy1rvMJxirdQ1zoV8i5z71hArG5tsKWOJp8YQGWNDLt+nI7i+UcM6VXL0dgeu3kNfn8L87/UKEGY0ZVXS4EYhIAO6uc9NjdLlDNyXY3bU+ASX09iQ65tPl8ClE/DBKD/G/YRQX2Qhy5zI/2GIkPGiyn5X5phRE4yRgo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758192044; c=relaxed/simple; bh=R8Xsmkzx7aOYm1jK65/dyFCdtO4BUsHKP1UuUfcs/ew=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q8NH3Ft2tmi2dI1DkoQpdEE1pMfKTnX3LKnMMUd6Jm3r6YhTBH3Tjka+ZH7qxeOhEsjXx+RQl8/kGE3BD4C+Q0fd1FIDJdL3QPeum19umurzW2DhUPhKjUNbXVgJnkFa74HeCVV2M3+uIFtiPEV8lbCPhcUy6StPnfa2tojvl9A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=ZJAf1huG; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="ZJAf1huG" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id DC5574E40D08; Thu, 18 Sep 2025 10:40:40 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id A81FA6062C; Thu, 18 Sep 2025 10:40:40 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id DECC4102F1D06; Thu, 18 Sep 2025 12:40:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1758192039; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=K6kewgS5GEy/Q8lFyYhTpZvLBbKsoFjT0ZyUNHYjTdo=; b=ZJAf1huGXR2YOfnuItyX9Wx0KPv8cX2ezVcYUprOCmFHvGma8wYiq8ZLre7FhTIDxoM6bR mdvj7O0yaHX7Dyz4F7zEW1E+4nNKCB833W/iEbtNpiuJurelinsgTG9WHyM7JZ3Db4EIbk IwQjmPb5RBWwVMa2JgiSrkBtdNWvCvy5Ole9TqWWaqk/9RTHNgfKdfoFE3qLp+b5FmIETT w2OGjs9O57XhvfcER+I8fRJgq//0wX7JDdRaPnZSiQeOuH3Zy3knvBs1wMMLPmKpg2c14l SLNyX6Did4U7hIsMBuD5zyivW92eKw9OIc1wiID/An5IT57cleXq0dgjlQZa+A== From: "Herve Codina (Schneider Electric)" To: Thomas Gleixner , Wolfram Sang , Hoan Tran , Linus Walleij , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm , Saravana Kannan , Serge Semin , Herve Codina Cc: Phil Edworthy , linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Pascal Eberhard , Miquel Raynal , Thomas Petazzoni Subject: [PATCH v3 6/8] dt-bindings: soc: renesas: Add the Renesas RZ/N1 GPIO Interrupt Multiplexer Date: Thu, 18 Sep 2025 12:40:04 +0200 Message-ID: <20250918104009.94754-7-herve.codina@bootlin.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250918104009.94754-1-herve.codina@bootlin.com> References: <20250918104009.94754-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" On the Renesas RZ/N1 SoC, GPIOs can generate interruptions. Those interruption lines are multiplexed by the GPIO Interrupt Multiplexer in order to map 32 * 3 GPIO interrupt lines to 8 GIC interrupt lines. The GPIO interrupt multiplexer IP does nothing but select 8 GPIO IRQ lines out of the 96 available to wire them to the GIC input lines. Signed-off-by: Herve Codina (Schneider Electric) Acked-by: Conor Dooley Tested-by: Wolfram Sang --- .../soc/renesas/renesas,rzn1-gpioirqmux.yaml | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/renesas/renesas,r= zn1-gpioirqmux.yaml diff --git a/Documentation/devicetree/bindings/soc/renesas/renesas,rzn1-gpi= oirqmux.yaml b/Documentation/devicetree/bindings/soc/renesas/renesas,rzn1-g= pioirqmux.yaml new file mode 100644 index 000000000000..21c6b6e1fa9a --- /dev/null +++ b/Documentation/devicetree/bindings/soc/renesas/renesas,rzn1-gpioirqmux= .yaml @@ -0,0 +1,87 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/soc/renesas/renesas,rzn1-gpioirqmux.yam= l# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Renesas RZ/N1 SoCs GPIO Interrupt Multiplexer + +description: | + The Renesas RZ/N1 GPIO Interrupt Multiplexer multiplexes GPIO interrupt + lines to the interrupt controller available in the SoC. + + It selects up to 8 of the 96 GPIO interrupt lines available and connect= them + to 8 output interrupt lines. + +maintainers: + - Herve Codina + +properties: + compatible: + items: + - enum: + - renesas,r9a06g032-gpioirqmux + - const: renesas,rzn1-gpioirqmux + + reg: + maxItems: 1 + + "#address-cells": + const: 0 + + "#interrupt-cells": + const: 1 + + interrupt-map-mask: + items: + - const: 0x7f + + interrupt-map: + description: + Specifies the mapping from external GPIO interrupt lines to the outp= ut + interrupts. The array items have to be ordered with the first item + related to the output line 0 (IRQ 103), the next one to the output l= ine 1 + (IRQ 104) and so on up to the output line 8 (IRQ 110). + +required: + - compatible + - reg + - "#address-cells" + - "#interrupt-cells" + - interrupt-map-mask + - interrupt-map + +additionalProperties: false + +examples: + - | + #include + + gic: interrupt-controller { + interrupt-controller; + #address-cells =3D <0>; + #interrupt-cells =3D <3>; + }; + + interrupt-controller@51000480 { + compatible =3D "renesas,r9a06g032-gpioirqmux", "renesas,rzn1-gpioi= rqmux"; + reg =3D <0x51000480 0x20>; + #address-cells =3D <0>; + #interrupt-cells =3D <1>; + interrupt-map-mask =3D <0x7f>; + /* + * The child interrupt number is computed using the following form= ula: + * gpio_bank * 32 + gpio_number + * + * with: + * - gpio_bank: The GPIO bank number + * - 0 for GPIO0A, + * - 1 for GPIO1A, + * - 2 for GPIO2A + * - gpio_number: Number of the gpio in the bank (0..31) + */ + interrupt-map =3D + <32 &gic GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>, /* GPIO1A.0 */ + <89 &gic GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>, /* GPIO2A.25 */ + <9 &gic GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>; /* GPIO0A.9 */ + }; --=20 2.51.0 From nobody Thu Oct 2 09:22:11 2025 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E446C2FFF8A; Thu, 18 Sep 2025 10:40:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758192046; cv=none; b=Bte3PJnMRzc0axdQN6Xn2545PXfHPKk97gGEifw8J9OP7u04J9XD0zxJJz5LXtbY8GzIZp88IrbH/M7wrCtiKZl2iNiyHRfbe28tQxZ2ca9ewIqLQlBpKjduTGZWBuR0mDsF7KzURak9lxeMQnzGvNmDG/r5ChAyNhQbldwktHQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758192046; c=relaxed/simple; bh=dndIw7FY0vB6XNMwaNprdOxuasKUV84FFdOaGqsO3Cc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Dr/BNWaKoF12OdWhyOmXtcD5mUMEP/wvYn9esQLXpB23frJXRkf5P53SYBtcnKFk4q3CTF4G4ITFAk0Ansyyb8Lx7MLoLtDv0yK1z1iFuPqISe0oHQOhZSRnOWLdrdneco9gdXP42uZ7nZCeyi9fgc7Dup0cqa9xpLcO0hsFk68= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=UgEAW4f/; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="UgEAW4f/" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 6CF2A4E40D0B; Thu, 18 Sep 2025 10:40:43 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 439F26062C; Thu, 18 Sep 2025 10:40:43 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 3C55E102F1D07; Thu, 18 Sep 2025 12:40:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1758192042; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=Oih+z7DRki3/W3NXwG40HAfWX9fZXZjpXuzwRdxWrcw=; b=UgEAW4f/DyoVkm7T2FCcpmZQfQCZzkmGZ/3kOfRLKXS62dP/WdogW9bvMX2iJW5Vcuwilb pEQ+1xWlUg0VvgEjHwiew8iIqLfUm2+K/stJZyqk2+fcJBN2BDWuoVfWRItqnBJQyORVyD Z/9Hv0X5cz92kr8aU9kJ0ruS4aonyjnQX50E6/i/rxeEl7+itRK/kbXmJz8t60tLEP2G5h pjPXGGQEYIngFNH35bS5lFPJSrbqrhiquvNHLOLJYvislrpOGQTqzGPkrrIrml/YhFvgQA bGubzjMFMuRgS4PAbtm4owvfqzM294gjHddUH65hiXSW2rZ/hV5K4bFTKs6Hyw== From: "Herve Codina (Schneider Electric)" To: Thomas Gleixner , Wolfram Sang , Hoan Tran , Linus Walleij , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm , Saravana Kannan , Serge Semin , Herve Codina Cc: Phil Edworthy , linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Pascal Eberhard , Miquel Raynal , Thomas Petazzoni Subject: [PATCH v3 7/8] soc: renesas: Add support for Renesas RZ/N1 GPIO Interrupt Multiplexer Date: Thu, 18 Sep 2025 12:40:05 +0200 Message-ID: <20250918104009.94754-8-herve.codina@bootlin.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250918104009.94754-1-herve.codina@bootlin.com> References: <20250918104009.94754-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" On the Renesas RZ/N1 SoC, GPIOs can generate interruptions. Those interruption lines are multiplexed by the GPIO Interrupt Multiplexer in order to map 32 * 3 GPIO interrupt lines to 8 GIC interrupt lines. The GPIO interrupt multiplexer IP does nothing but select 8 GPIO IRQ lines out of the 96 available to wire them to the GIC input lines. Signed-off-by: Herve Codina (Schneider Electric) Tested-by: Wolfram Sang --- drivers/soc/renesas/Kconfig | 4 ++ drivers/soc/renesas/Makefile | 1 + drivers/soc/renesas/rzn1_irqmux.c | 110 ++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 drivers/soc/renesas/rzn1_irqmux.c diff --git a/drivers/soc/renesas/Kconfig b/drivers/soc/renesas/Kconfig index 719b7f4f376f..0878b6884515 100644 --- a/drivers/soc/renesas/Kconfig +++ b/drivers/soc/renesas/Kconfig @@ -58,6 +58,7 @@ config ARCH_RZN1 select PM select PM_GENERIC_DOMAINS select ARM_AMBA + select RZN1_IRQMUX =20 if ARM && ARCH_RENESAS =20 @@ -447,6 +448,9 @@ config PWC_RZV2M config RST_RCAR bool "Reset Controller support for R-Car" if COMPILE_TEST =20 +config RZN1_IRQMUX + bool "Renesas RZ/N1 GPIO IRQ multiplexer support" if COMPILE_TEST + config SYSC_RZ bool "System controller for RZ SoCs" if COMPILE_TEST =20 diff --git a/drivers/soc/renesas/Makefile b/drivers/soc/renesas/Makefile index 3bdcc6a395d5..daa932c7698d 100644 --- a/drivers/soc/renesas/Makefile +++ b/drivers/soc/renesas/Makefile @@ -14,4 +14,5 @@ obj-$(CONFIG_SYS_R9A09G057) +=3D r9a09g057-sys.o # Family obj-$(CONFIG_PWC_RZV2M) +=3D pwc-rzv2m.o obj-$(CONFIG_RST_RCAR) +=3D rcar-rst.o +obj-$(CONFIG_RZN1_IRQMUX) +=3D rzn1_irqmux.o obj-$(CONFIG_SYSC_RZ) +=3D rz-sysc.o diff --git a/drivers/soc/renesas/rzn1_irqmux.c b/drivers/soc/renesas/rzn1_i= rqmux.c new file mode 100644 index 000000000000..3855e132c15f --- /dev/null +++ b/drivers/soc/renesas/rzn1_irqmux.c @@ -0,0 +1,110 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * RZ/N1 GPIO Interrupt Multiplexer + * + * Copyright 2025 Schneider Electric + * Author: Herve Codina + */ + +#include +#include +#include +#include +#include + +#define IRQMUX_MAX_IRQS 8 + +static int irqmux_setup(struct device *dev, struct device_node *np, u32 __= iomem *regs) +{ + struct of_imap_parser imap_parser; + struct of_imap_item imap_item; + unsigned int index =3D 0; + u32 tmp; + int ret; + + /* We support only #interrupt-cells =3D <1> and #address-cells =3D <0> */ + ret =3D of_property_read_u32(np, "#interrupt-cells", &tmp); + if (ret) + return ret; + if (tmp !=3D 1) + return -EINVAL; + + ret =3D of_property_read_u32(np, "#address-cells", &tmp); + if (ret) + return ret; + if (tmp !=3D 0) + return -EINVAL; + + ret =3D of_imap_parser_init(&imap_parser, np, &imap_item); + if (ret) + return ret; + + for_each_of_imap_item(&imap_parser, &imap_item) { + /* + * The child #address-cells is 0 (already checked). The first + * value in imap item is the src hwirq. + * + * imap items matches 1:1 the interrupt lines that could + * be configured by registers (same order, same number). + * Configure the related register with the src hwirq retrieved + * from the interrupt-map. + */ + if (index > IRQMUX_MAX_IRQS) { + of_node_put(imap_item.parent_args.np); + dev_err(dev, "too much items in interrupt-map\n"); + return -EINVAL; + } + + writel(imap_item.child_imap[0], regs + index); + index++; + } + + return 0; +} + +static int irqmux_probe(struct platform_device *pdev) +{ + struct device *dev =3D &pdev->dev; + struct device_node *np =3D dev->of_node; + u32 __iomem *regs; + int nr_irqs; + int ret; + + regs =3D devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(regs)) + return PTR_ERR(regs); + + nr_irqs =3D of_irq_count(np); + if (nr_irqs < 0) + return nr_irqs; + + if (nr_irqs > IRQMUX_MAX_IRQS) { + dev_err(dev, "too many output interrupts\n"); + return -ENOENT; + } + + ret =3D irqmux_setup(dev, np, regs); + if (ret) + return dev_err_probe(dev, ret, "failed to setup mux\n"); + + return 0; +} + +static const struct of_device_id irqmux_of_match[] =3D { + { .compatible =3D "renesas,rzn1-gpioirqmux", }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, irq_mux_of_match); + +static struct platform_driver irqmux_driver =3D { + .probe =3D irqmux_probe, + .driver =3D { + .name =3D "rzn1_irqmux", + .of_match_table =3D irqmux_of_match, + }, +}; +module_platform_driver(irqmux_driver); + +MODULE_AUTHOR("Herve Codina "); +MODULE_DESCRIPTION("Renesas RZ/N1 GPIO IRQ Multiplexer Driver"); +MODULE_LICENSE("GPL"); --=20 2.51.0 From nobody Thu Oct 2 09:22:11 2025 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCB373002C1; Thu, 18 Sep 2025 10:40:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758192048; cv=none; b=pclaGdcFdtnsL3zRK/qq9DP//qtD9bzcduf1xY4nDCSUO96GVstx2FSjb6uahX3xVGfuPrrIKZDcSf6y4io49Krawx9WeUpxA6FRd7QMudZTzrJ1Y61fK4TZ2XUQP5sit6RgltVJXnuacy+Ub+L4oFPFFHbBGhVMGqxLrirJbyw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758192048; c=relaxed/simple; bh=+WJqQHU+nIQgBo0Zz0TjudEqKyicGjZv7sGjdPPKqDE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AwERlXwJ2m3tn1hQQi+ZZtJByYzQLWj+1bbSSF/htvMVFNmP/y9jN4TrPDJkp7KnhyK0WneNJ+Tg47CfoEKP/ArjcfckwGQbrmxO1MyYfbcMSw7TcULhDHY6S182G9WSlLYTpLJ+2bgwwUCKIPYxPKlDJv/O15dPt8iqlO+cG6E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=HbdF/8zF; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="HbdF/8zF" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id C6AAEC00091; Thu, 18 Sep 2025 10:40:28 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 62CFD6062C; Thu, 18 Sep 2025 10:40:45 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id ABD01102F1CD5; Thu, 18 Sep 2025 12:40:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1758192044; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=ioi2JebbHDsN+5FlqVwYbemd6/RDAm9gDaAPNluL0IM=; b=HbdF/8zFiZtAJE4MKFpviq1LQP2cDXKfmdbE1Igfusnk2bYr31XeJJAo6lq5wWdiMAKKEs F90PJ6VuZZya4Xfx5DFadj+qC0MvPM0/v8rGmJLWBSvcHVYzwGSVEFuQ9aoINd3HTNtZpJ WhEOkZBAAuVvjcwcKw2hjhGzeHA3tKgoIYV8GtOyAQhJMJxhYE0hnn0twiKcfegxXbhSge IxB9zr5k+GJf2vzNDTsJDvALIC9xXep50r/CHApYo5cwHtHTYZcVBO2kvxx62QlH1R8N+Q 1fwbrvMfTkswNO8s5Hc5JO/oMZDgb44l24EYAquZ9Cc7IO1FzNygj8w5zro6cg== From: "Herve Codina (Schneider Electric)" To: Thomas Gleixner , Wolfram Sang , Hoan Tran , Linus Walleij , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm , Saravana Kannan , Serge Semin , Herve Codina Cc: Phil Edworthy , linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Pascal Eberhard , Miquel Raynal , Thomas Petazzoni Subject: [PATCH v3 8/8] ARM: dts: r9a06g032: Add support for GPIO interrupts Date: Thu, 18 Sep 2025 12:40:06 +0200 Message-ID: <20250918104009.94754-9-herve.codina@bootlin.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250918104009.94754-1-herve.codina@bootlin.com> References: <20250918104009.94754-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" In the RZ/N1 SoC, the GPIO interrupts are multiplexed using the GPIO Interrupt Multiplexer. Add the multiplexer node and connect GPIO interrupt lines to the multiplexer. The interrupt-map available in the multiplexer node has to be updated in dts files depending on the GPIO usage. Indeed, the usage of an interrupt for a GPIO is board dependent. Up to 8 GPIOs can be used as an interrupt line (one per multiplexer output interrupt). Signed-off-by: Herve Codina (Schneider Electric) Tested-by: Wolfram Sang --- arch/arm/boot/dts/renesas/r9a06g032.dtsi | 49 ++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/arch/arm/boot/dts/renesas/r9a06g032.dtsi b/arch/arm/boot/dts/r= enesas/r9a06g032.dtsi index da977cdd8487..3cd7ac38eb7a 100644 --- a/arch/arm/boot/dts/renesas/r9a06g032.dtsi +++ b/arch/arm/boot/dts/renesas/r9a06g032.dtsi @@ -534,6 +534,14 @@ gpio0a: gpio-port@0 { #gpio-cells =3D <2>; snps,nr-gpios =3D <32>; reg =3D <0>; + + interrupt-controller; + interrupt-parent =3D <&gpioirqmux>; + interrupts =3D < 0 1 2 3 4 5 6 7 + 8 9 10 11 12 13 14 15 + 16 17 18 19 20 21 22 23 + 24 25 26 27 28 29 30 31 >; + #interrupt-cells =3D <2>; }; =20 /* GPIO0b[0..1] connected to pins GPIO1..2 */ @@ -576,6 +584,14 @@ gpio1a: gpio-port@0 { #gpio-cells =3D <2>; snps,nr-gpios =3D <32>; reg =3D <0>; + + interrupt-controller; + interrupt-parent =3D <&gpioirqmux>; + interrupts =3D < 32 33 34 35 36 37 38 39 + 40 41 42 43 44 45 46 47 + 48 49 50 51 52 53 54 55 + 56 57 58 59 60 61 62 63 >; + #interrupt-cells =3D <2>; }; =20 /* GPIO1b[0..1] connected to pins GPIO55..56 */ @@ -608,6 +624,14 @@ gpio2a: gpio-port@0 { #gpio-cells =3D <2>; snps,nr-gpios =3D <32>; reg =3D <0>; + + interrupt-controller; + interrupt-parent =3D <&gpioirqmux>; + interrupts =3D < 64 65 66 67 68 69 70 71 + 72 73 74 75 76 77 78 79 + 80 81 82 83 84 85 86 87 + 88 89 90 91 92 93 94 95 >; + #interrupt-cells =3D <2>; }; =20 /* GPIO2b[0..9] connected to pins GPIO160..169 */ @@ -620,6 +644,31 @@ gpio2b: gpio-port@1 { }; }; =20 + gpioirqmux: interrupt-controller@51000480 { + compatible =3D "renesas,r9a06g032-gpioirqmux", "renesas,rzn1-gpioirqmux= "; + reg =3D <0x51000480 0x20>; + #interrupt-cells =3D <1>; + #address-cells =3D <0>; + interrupt-map-mask =3D <0x7f>; + + /* + * interrupt-map has to be updated according to GPIO + * usage. The order has to be kept. Only the src irq + * (0 field) has to be updated with the needed GPIO + * interrupt number. + */ + interrupt-map =3D <0 &gic GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>, + <0 &gic GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>, + <0 &gic GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>, + <0 &gic GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>, + <0 &gic GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>, + <0 &gic GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>, + <0 &gic GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH>, + <0 &gic GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH>; + + status =3D "disabled"; + }; + can0: can@52104000 { compatible =3D "renesas,r9a06g032-sja1000", "renesas,rzn1-sja1000"; reg =3D <0x52104000 0x800>; --=20 2.51.0