* [PATCH v8 01/15] dt-bindings: pwm: rzg2l-gpt: Document renesas,poegs property
2025-11-21 16:08 [PATCH v8 00/15] Add RZ/G2L POEG support Biju
@ 2025-11-21 16:08 ` Biju
2025-11-21 16:08 ` [PATCH v8 02/15] pwm: rzg2l-gpt: Add support for gpt linking with poeg Biju
` (14 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Biju @ 2025-11-21 16:08 UTC (permalink / raw)
To: Uwe Kleine-König, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Geert Uytterhoeven, Magnus Damm
Cc: Biju Das, linux-pwm, devicetree, linux-kernel, linux-renesas-soc,
Prabhakar Mahadev Lad, Biju Das
From: Biju Das <biju.das.jz@bp.renesas.com>
RZ/G2L GPT IP supports output pin disable function by dead time
error and detecting short-circuits between output pins.
Add documentation for the optional property renesas,poegs to
link a pair of GPT IOs with POEG.
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
V24 from [1] -> v8:
* No change
[1] https://lore.kernel.org/all/20250226144531.176819-1-biju.das.jz@bp.renesas.com/
---
.../bindings/pwm/renesas,rzg2l-gpt.yaml | 23 +++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/Documentation/devicetree/bindings/pwm/renesas,rzg2l-gpt.yaml b/Documentation/devicetree/bindings/pwm/renesas,rzg2l-gpt.yaml
index 13b807765a30..98bcde755fb9 100644
--- a/Documentation/devicetree/bindings/pwm/renesas,rzg2l-gpt.yaml
+++ b/Documentation/devicetree/bindings/pwm/renesas,rzg2l-gpt.yaml
@@ -245,6 +245,28 @@ properties:
resets:
maxItems: 1
+ renesas,poegs:
+ minItems: 1
+ maxItems: 8
+ $ref: /schemas/types.yaml#/definitions/phandle-array
+ items:
+ items:
+ - description: phandle to POEG instance that serves the output disable
+ - enum: [ 0, 1, 2, 3, 4, 5, 6, 7 ]
+ description: |
+ An index identifying pair of GPT channels.
+ <0> : GPT channels 0 and 1
+ <1> : GPT channels 2 and 3
+ <2> : GPT channels 4 and 5
+ <3> : GPT channels 6 and 7
+ <4> : GPT channels 8 and 9
+ <5> : GPT channels 10 and 11
+ <6> : GPT channels 12 and 13
+ <7> : GPT channels 14 and 15
+ description:
+ A list of phandle and channel index pair tuples to the POEGs that handle the
+ output disable for the GPT channels.
+
required:
- compatible
- reg
@@ -375,4 +397,5 @@ examples:
power-domains = <&cpg>;
resets = <&cpg R9A07G044_GPT_RST_C>;
#pwm-cells = <3>;
+ renesas,poegs = <&poeggd 4>;
};
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH v8 02/15] pwm: rzg2l-gpt: Add support for gpt linking with poeg
2025-11-21 16:08 [PATCH v8 00/15] Add RZ/G2L POEG support Biju
2025-11-21 16:08 ` [PATCH v8 01/15] dt-bindings: pwm: rzg2l-gpt: Document renesas,poegs property Biju
@ 2025-11-21 16:08 ` Biju
2025-11-21 16:08 ` [PATCH v8 03/15] dt-bindings: pinctrl: rzg2l-poeg: Document renesas,poeg-config property Biju
` (13 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Biju @ 2025-11-21 16:08 UTC (permalink / raw)
To: Uwe Kleine-König, Geert Uytterhoeven, Magnus Damm
Cc: Biju Das, linux-pwm, linux-kernel, linux-renesas-soc,
Prabhakar Mahadev Lad, Biju Das
From: Biju Das <biju.das.jz@bp.renesas.com>
The General PWM Timer (GPT) is capable of detecting "dead time error
and short-circuits between output pins" and send Output disable
request to poeg(Port Output Enable for GPT).
Add support for linking poeg group with gpt, so that gpt can control
the output disable function.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
V24 from [1] -> v8:
* Replaced return type of rzg2l_gpt_poeg_init() from void->int and
probe() checks this return value.
* Added more error checks in rzg2l_gpt_poeg_init()
[1] https://lore.kernel.org/all/20250226144531.176819-1-biju.das.jz@bp.renesas.com/
---
drivers/pwm/pwm-rzg2l-gpt.c | 95 +++++++++++++++++++++++++++++++++++++
1 file changed, 95 insertions(+)
diff --git a/drivers/pwm/pwm-rzg2l-gpt.c b/drivers/pwm/pwm-rzg2l-gpt.c
index 38ad03ded9ce..aabd2d576231 100644
--- a/drivers/pwm/pwm-rzg2l-gpt.c
+++ b/drivers/pwm/pwm-rzg2l-gpt.c
@@ -39,6 +39,7 @@
#define RZG2L_GTCR(ch) (0x2c + RZG2L_GET_CH_OFFS(ch))
#define RZG2L_GTUDDTYC(ch) (0x30 + RZG2L_GET_CH_OFFS(ch))
#define RZG2L_GTIOR(ch) (0x34 + RZG2L_GET_CH_OFFS(ch))
+#define RZG2L_GTINTAD(ch) (0x38 + RZG2L_GET_CH_OFFS(ch))
#define RZG2L_GTBER(ch) (0x40 + RZG2L_GET_CH_OFFS(ch))
#define RZG2L_GTCNT(ch) (0x48 + RZG2L_GET_CH_OFFS(ch))
#define RZG2L_GTCCR(ch, sub_ch) (0x4c + RZG2L_GET_CH_OFFS(ch) + 4 * (sub_ch))
@@ -55,12 +56,21 @@
#define RZG2L_GTUDDTYC_UP_COUNTING (RZG2L_GTUDDTYC_UP | RZG2L_GTUDDTYC_UDF)
#define RZG2L_GTIOR_GTIOA GENMASK(4, 0)
+#define RZG2L_GTIOR_OADF GENMASK(10, 9)
#define RZG2L_GTIOR_GTIOB GENMASK(20, 16)
+#define RZG2L_GTIOR_OBDF GENMASK(26, 25)
+
#define RZG2L_GTIOR_GTIOx(sub_ch) ((sub_ch) ? RZG2L_GTIOR_GTIOB : RZG2L_GTIOR_GTIOA)
+
#define RZG2L_GTIOR_OAE BIT(8)
#define RZG2L_GTIOR_OBE BIT(24)
#define RZG2L_GTIOR_OxE(sub_ch) ((sub_ch) ? RZG2L_GTIOR_OBE : RZG2L_GTIOR_OAE)
+#define RZG2L_GTIOR_OADF_HIGH_IMP_ON_OUT_DISABLE BIT(9)
+#define RZG2L_GTIOR_OBDF_HIGH_IMP_ON_OUT_DISABLE BIT(25)
+#define RZG2L_GTIOR_PIN_DISABLE_SETTING \
+ (RZG2L_GTIOR_OADF_HIGH_IMP_ON_OUT_DISABLE | RZG2L_GTIOR_OBDF_HIGH_IMP_ON_OUT_DISABLE)
+
#define RZG2L_INIT_OUT_HI_OUT_HI_END_TOGGLE 0x1b
#define RZG2L_GTIOR_GTIOA_OUT_HI_END_TOGGLE_CMP_MATCH \
(RZG2L_INIT_OUT_HI_OUT_HI_END_TOGGLE | RZG2L_GTIOR_OAE)
@@ -71,12 +81,17 @@
((sub_ch) ? RZG2L_GTIOR_GTIOB_OUT_HI_END_TOGGLE_CMP_MATCH : \
RZG2L_GTIOR_GTIOA_OUT_HI_END_TOGGLE_CMP_MATCH)
+#define RZG2L_GTINTAD_GRP_MASK GENMASK(25, 24)
+
#define RZG2L_MAX_HW_CHANNELS 8
#define RZG2L_CHANNELS_PER_IO 2
#define RZG2L_MAX_PWM_CHANNELS (RZG2L_MAX_HW_CHANNELS * RZG2L_CHANNELS_PER_IO)
#define RZG2L_MAX_SCALE_FACTOR 1024
#define RZG2L_MAX_TICKS ((u64)U32_MAX * RZG2L_MAX_SCALE_FACTOR)
+#define RZG2L_MAX_POEG_GROUPS 4
+#define RZG2L_LAST_POEG_GROUP 3
+
struct rzg2l_gpt_chip {
void __iomem *mmio;
struct mutex lock; /* lock to protect shared channel resources */
@@ -84,6 +99,7 @@ struct rzg2l_gpt_chip {
u32 period_ticks[RZG2L_MAX_HW_CHANNELS];
u32 channel_request_count[RZG2L_MAX_HW_CHANNELS];
u32 channel_enable_count[RZG2L_MAX_HW_CHANNELS];
+ DECLARE_BITMAP(poeg_gpt_link, RZG2L_MAX_POEG_GROUPS * RZG2L_MAX_HW_CHANNELS);
};
static inline struct rzg2l_gpt_chip *to_rzg2l_gpt_chip(struct pwm_chip *chip)
@@ -379,6 +395,81 @@ static const struct pwm_ops rzg2l_gpt_ops = {
.apply = rzg2l_gpt_apply,
};
+/*
+ * This function links a poeg group{A,B,C,D} with a gpt channel{0..7} and
+ * configure the pin for output disable.
+ */
+static int rzg2l_gpt_poeg_init(struct platform_device *pdev,
+ struct rzg2l_gpt_chip *rzg2l_gpt)
+{
+ const char *poeg_name = "renesas,poegs";
+ struct of_phandle_args of_args;
+ struct property *poegs;
+ unsigned int i;
+ u32 poeg_grp;
+ u32 bitpos;
+ int cells;
+ int ret;
+
+ poegs = of_find_property(pdev->dev.of_node, poeg_name, NULL);
+ if (!poegs)
+ return 0;
+
+ cells = of_property_count_u32_elems(pdev->dev.of_node, poeg_name);
+ if (cells < 0)
+ return cells;
+
+ if (cells & 1)
+ return -EINVAL;
+
+ cells >>= 1;
+ for (i = 0; i < cells; i++) {
+ ret = of_parse_phandle_with_fixed_args(pdev->dev.of_node,
+ poeg_name, 1, i,
+ &of_args);
+ if (ret)
+ return ret;
+
+ if (of_args.args[0] >= RZG2L_MAX_HW_CHANNELS) {
+ dev_err(&pdev->dev, "Invalid channel %d >= %d\n",
+ of_args.args[0], RZG2L_MAX_HW_CHANNELS);
+ goto err_of_node;
+ }
+
+ if (!of_device_is_available(of_args.np)) {
+ /* It's fine to have a phandle to a non-enabled poeg. */
+ of_node_put(of_args.np);
+ continue;
+ }
+
+ if (!of_property_read_u32(of_args.np, "renesas,poeg-id", &poeg_grp)) {
+ if (poeg_grp > RZG2L_LAST_POEG_GROUP) {
+ dev_err(&pdev->dev, "Invalid poeg group %d > %d\n",
+ poeg_grp, RZG2L_LAST_POEG_GROUP);
+ goto err_of_node;
+ }
+
+ bitpos = of_args.args[0] + poeg_grp * RZG2L_MAX_HW_CHANNELS;
+ set_bit(bitpos, rzg2l_gpt->poeg_gpt_link);
+
+ rzg2l_gpt_modify(rzg2l_gpt, RZG2L_GTINTAD(of_args.args[0]),
+ RZG2L_GTINTAD_GRP_MASK, poeg_grp << 24);
+
+ rzg2l_gpt_modify(rzg2l_gpt, RZG2L_GTIOR(of_args.args[0]),
+ RZG2L_GTIOR_OBDF | RZG2L_GTIOR_OADF,
+ RZG2L_GTIOR_PIN_DISABLE_SETTING);
+ }
+
+ of_node_put(of_args.np);
+ }
+
+ return 0;
+
+err_of_node:
+ of_node_put(of_args.np);
+ return -EINVAL;
+}
+
static int rzg2l_gpt_probe(struct platform_device *pdev)
{
struct rzg2l_gpt_chip *rzg2l_gpt;
@@ -430,6 +521,10 @@ static int rzg2l_gpt_probe(struct platform_device *pdev)
if (rzg2l_gpt->rate_khz * KILO != rate)
return dev_err_probe(dev, -EINVAL, "Rate is not multiple of 1000");
+ ret = rzg2l_gpt_poeg_init(pdev, rzg2l_gpt);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to link gpt with poeg\n");
+
mutex_init(&rzg2l_gpt->lock);
chip->ops = &rzg2l_gpt_ops;
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH v8 03/15] dt-bindings: pinctrl: rzg2l-poeg: Document renesas,poeg-config property
2025-11-21 16:08 [PATCH v8 00/15] Add RZ/G2L POEG support Biju
2025-11-21 16:08 ` [PATCH v8 01/15] dt-bindings: pwm: rzg2l-gpt: Document renesas,poegs property Biju
2025-11-21 16:08 ` [PATCH v8 02/15] pwm: rzg2l-gpt: Add support for gpt linking with poeg Biju
@ 2025-11-21 16:08 ` Biju
2025-11-21 16:08 ` [PATCH v8 04/15] drivers: pinctrl: renesas: Add RZ/G2L POEG driver support Biju
` (12 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Biju @ 2025-11-21 16:08 UTC (permalink / raw)
To: Geert Uytterhoeven, Linus Walleij, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Magnus Damm
Cc: Biju Das, linux-renesas-soc, linux-gpio, devicetree, linux-kernel,
Prabhakar Mahadev Lad, Biju Das
From: Biju Das <biju.das.jz@bp.renesas.com>
Document renesas,poeg-config optional property.
The output pins of the general PWM timer (GPT) can be disabled by using
the port output enabling function for the GPT (POEG). The HW supports
following ways to disable the output pins.
1) Pin output disable by input level detection of the GTETRG{A..D} pins
2) Output disable request from the GPT
3) Pin output disable by user control
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v7->v8:
* Add ack from Rob and Linus Walleij.
v7:
* New patch
---
.../bindings/pinctrl/renesas,rzg2l-poeg.yaml | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/Documentation/devicetree/bindings/pinctrl/renesas,rzg2l-poeg.yaml b/Documentation/devicetree/bindings/pinctrl/renesas,rzg2l-poeg.yaml
index ab2d456c93e4..ae027a490206 100644
--- a/Documentation/devicetree/bindings/pinctrl/renesas,rzg2l-poeg.yaml
+++ b/Documentation/devicetree/bindings/pinctrl/renesas,rzg2l-poeg.yaml
@@ -57,6 +57,21 @@ properties:
<2> : POEG group C
<3> : POEG group D
+ renesas,poeg-config:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ enum: [ 1, 2, 4, 6, 8, 10, 12, 14, 16 ]
+ description: |
+ POEG Configuration. Valid values are:
+ <1> : User control
+ <2> : GPT both output high
+ <4> : GPT both output low
+ <6> : GPT both output high + GPT both output low
+ <8> : GPT dead time error
+ <10> : GPT both output high + GPT dead time error
+ <12> : GPT both output low + GPT dead time error
+ <14> : GPT both output {high, low} + GPT dead time error
+ <16> : External pin control
+
required:
- compatible
- reg
@@ -83,4 +98,5 @@ examples:
resets = <&cpg R9A07G044_POEG_D_RST>;
renesas,poeg-id = <3>;
renesas,gpt = <&gpt>;
+ renesas,poeg-config = <1>;
};
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH v8 04/15] drivers: pinctrl: renesas: Add RZ/G2L POEG driver support
2025-11-21 16:08 [PATCH v8 00/15] Add RZ/G2L POEG support Biju
` (2 preceding siblings ...)
2025-11-21 16:08 ` [PATCH v8 03/15] dt-bindings: pinctrl: rzg2l-poeg: Document renesas,poeg-config property Biju
@ 2025-11-21 16:08 ` Biju
2025-11-21 16:08 ` [PATCH v8 05/15] arm64: dts: renesas: r9a07g0{4,5}4: Add POEG nodes Biju
` (11 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Biju @ 2025-11-21 16:08 UTC (permalink / raw)
To: Geert Uytterhoeven, Linus Walleij, Philipp Zabel, Magnus Damm
Cc: Biju Das, linux-kernel, linux-renesas-soc, linux-gpio,
Prabhakar Mahadev Lad, Biju Das
From: Biju Das <biju.das.jz@bp.renesas.com>
The output pins of the RZ/G2L general PWM timer (GPT) can be disabled
by using the port output enabling function for the GPT (POEG).
Add basic support for user control and output-disable requests from the
GTETRGn pins by using poeg char device.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v7->v8:
* Replaced config name from POEG_RZG2L->RENESAS_RZG2L_POEG.
* Updated POEG Kconfig dependency with PWM
* Dropped static variable minor_n and instead using the value of
"renesas,poeg-id".
* Replaced devm_reset_*_exclusive()->devm_reset_*_exclusive_deasserted()
* Replaced pm_runtime_enable() with devm variant.
* Added support for handling output-disable requests from the GTETRGn
pins.
* Replaced the macros RZG2L_POEG_USR_CTRL_{EN,DiS}ABLE_CMD to
RZG2L_POEG_OUTPUT_DISABLE_USR_{EN,DIS}ABLE_CMD.
* Replaced '&pdev->dev' by 'dev' in probe().
v6->v7:
* Used DT to handle the system configuration
* Added poeg char device for user control support to enable/disable
output from GPT
* Replaced iowrite32/ioread32-> writel/readl
* Dropped of_match_ptr from .of_match_table
v5->v6:
* Dropped sysfs and is handled in generic driver.
v4->v5:
* Updated kernel version in sysfs doc.
v3->v4:
* Updated commit description.
v2->v3:
* Added sysfs documentation for output_disable
* PWM_RZG2L_GPT implies ARCH_RZG2L. So removed ARCH_RZG2L dependency
* Used dev_get_drvdata to get device data
* Replaced sprintf->sysfs_emit in show().
v1->v2:
* Renamed the file poeg-rzg2l->rzg2l-poeg
* Removed the macro POEGG as there is only single register and
updated rzg2l_poeg_write() and rzg2l_poeg_read()
* Updated error handling in probe()
Ref->v1:
* Moved driver files from soc to pincontrol directory
* Updated KConfig
---
drivers/pinctrl/renesas/Kconfig | 2 +
drivers/pinctrl/renesas/Makefile | 2 +
drivers/pinctrl/renesas/poeg/Kconfig | 11 +
drivers/pinctrl/renesas/poeg/Makefile | 2 +
drivers/pinctrl/renesas/poeg/rzg2l-poeg.c | 368 ++++++++++++++++++++++
include/linux/pinctrl/rzg2l-poeg.h | 15 +
6 files changed, 400 insertions(+)
create mode 100644 drivers/pinctrl/renesas/poeg/Kconfig
create mode 100644 drivers/pinctrl/renesas/poeg/Makefile
create mode 100644 drivers/pinctrl/renesas/poeg/rzg2l-poeg.c
create mode 100644 include/linux/pinctrl/rzg2l-poeg.h
diff --git a/drivers/pinctrl/renesas/Kconfig b/drivers/pinctrl/renesas/Kconfig
index 8cbd79a13414..dc95b7020d30 100644
--- a/drivers/pinctrl/renesas/Kconfig
+++ b/drivers/pinctrl/renesas/Kconfig
@@ -326,4 +326,6 @@ config PINCTRL_RZV2M
This selects GPIO and pinctrl driver for Renesas RZ/V2M
platforms.
+source "drivers/pinctrl/renesas/poeg/Kconfig"
+
endmenu
diff --git a/drivers/pinctrl/renesas/Makefile b/drivers/pinctrl/renesas/Makefile
index 1c5144a1c4b8..8dc5da978a45 100644
--- a/drivers/pinctrl/renesas/Makefile
+++ b/drivers/pinctrl/renesas/Makefile
@@ -53,6 +53,8 @@ obj-$(CONFIG_PINCTRL_RZN1) += pinctrl-rzn1.o
obj-$(CONFIG_PINCTRL_RZT2H) += pinctrl-rzt2h.o
obj-$(CONFIG_PINCTRL_RZV2M) += pinctrl-rzv2m.o
+obj-$(CONFIG_RENESAS_RZG2L_POEG) += poeg/
+
ifeq ($(CONFIG_COMPILE_TEST),y)
CFLAGS_pfc-sh7203.o += -I$(srctree)/arch/sh/include/cpu-sh2a
CFLAGS_pfc-sh7264.o += -I$(srctree)/arch/sh/include/cpu-sh2a
diff --git a/drivers/pinctrl/renesas/poeg/Kconfig b/drivers/pinctrl/renesas/poeg/Kconfig
new file mode 100644
index 000000000000..621a4ce72c72
--- /dev/null
+++ b/drivers/pinctrl/renesas/poeg/Kconfig
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0
+config RENESAS_RZG2L_POEG
+ tristate "Renesas RZ/G2L poeg support"
+ depends on PWM_RENESAS_RZG2L_GPT || COMPILE_TEST
+ depends on HAS_IOMEM
+ help
+ This driver exposes the Port Output Enable for GPT(POEG) found
+ in Renesas RZ/G2L alike SoCs.
+
+ To compile this driver as a module, choose M here: the module
+ will be called rzg2l-poeg.
diff --git a/drivers/pinctrl/renesas/poeg/Makefile b/drivers/pinctrl/renesas/poeg/Makefile
new file mode 100644
index 000000000000..b0ed1e9a467a
--- /dev/null
+++ b/drivers/pinctrl/renesas/poeg/Makefile
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_RENESAS_RZG2L_POEG) += rzg2l-poeg.o
diff --git a/drivers/pinctrl/renesas/poeg/rzg2l-poeg.c b/drivers/pinctrl/renesas/poeg/rzg2l-poeg.c
new file mode 100644
index 000000000000..2a09888407d0
--- /dev/null
+++ b/drivers/pinctrl/renesas/poeg/rzg2l-poeg.c
@@ -0,0 +1,368 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Renesas RZ/G2L Port Output Enable for GPT (POEG) driver
+ *
+ * Copyright (C) 2023 Renesas Electronics Corporation
+ */
+#include <linux/cdev.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/kfifo.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+#include <linux/pinctrl/rzg2l-poeg.h>
+#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
+#include <linux/pinctrl/rzg2l-poeg.h>
+#include <linux/poll.h>
+#include <linux/reset.h>
+#include <linux/wait.h>
+
+#define POEGG_IOCE BIT(5)
+#define POEGG_PIDE BIT(4)
+#define POEGG_SSF BIT(3)
+#define POEGG_IOCF BIT(1)
+#define POEGG_PIDF BIT(0)
+
+#define RZG2L_POEG_MAX_INDEX 3
+
+#define RZG2L_GPT_MAX_HW_CHANNELS 8
+#define RZG2L_GPT_INVALID_CHANNEL 0xff
+
+enum poeg_conf {
+ POEG_USER_CTRL = BIT(0),
+ POEG_GPT_BOTH_HIGH = BIT(1),
+ POEG_GPT_BOTH_LOW = BIT(2),
+ POEG_GPT_DEAD_TIME = BIT(3),
+ POEG_EXT_PIN_CTRL = BIT(4),
+ POEG_GPT_BOTH_HIGH_LOW = BIT(1) | BIT(2),
+ POEG_GPT_BOTH_HIGH_DEAD_TIME = BIT(1) | BIT(3),
+ POEG_GPT_BOTH_LOW_DEAD_TIME = BIT(2) | BIT(3),
+ POEG_GPT_ALL = BIT(1) | BIT(2) | BIT(3)
+};
+
+static struct class *poeg_class;
+static dev_t g_poeg_dev;
+
+struct rzg2l_poeg_chip {
+ struct device *gpt_dev;
+ struct reset_control *rstc;
+ void __iomem *mmio;
+ struct cdev poeg_cdev;
+ u32 cfg;
+ int minor_n;
+ u8 gpt_channels[RZG2L_GPT_MAX_HW_CHANNELS];
+ u8 index;
+};
+
+static void rzg2l_poeg_write(struct rzg2l_poeg_chip *chip, u32 data)
+{
+ writel(data, chip->mmio);
+}
+
+static u32 rzg2l_poeg_read(struct rzg2l_poeg_chip *chip)
+{
+ return readl(chip->mmio);
+}
+
+static int rzg2l_poeg_output_disable_user(struct rzg2l_poeg_chip *chip, bool enable)
+{
+ u32 reg_val;
+
+ reg_val = rzg2l_poeg_read(chip);
+ if (enable)
+ reg_val |= POEGG_SSF;
+ else
+ reg_val &= ~POEGG_SSF;
+
+ rzg2l_poeg_write(chip, reg_val);
+
+ return 0;
+}
+
+static irqreturn_t rzg2l_poeg_irq(int irq, void *ptr)
+{
+ struct rzg2l_poeg_chip *chip = ptr;
+ u32 val;
+
+ val = rzg2l_poeg_read(chip);
+ if (val & POEGG_PIDF)
+ val &= ~POEGG_PIDF;
+
+ rzg2l_poeg_write(chip, val);
+
+ return IRQ_HANDLED;
+}
+
+static ssize_t rzg2l_poeg_chrdev_write(struct file *filp, const char __user *buf,
+ size_t len, loff_t *f_ps)
+{
+ struct rzg2l_poeg_chip *const chip = filp->private_data;
+ struct poeg_cmd cmd;
+
+ if (copy_from_user(&cmd, buf, sizeof(cmd)))
+ return -EFAULT;
+
+ switch (cmd.val) {
+ case RZG2L_POEG_OUTPUT_DISABLE_USR_ENABLE_CMD:
+ rzg2l_poeg_output_disable_user(chip, true);
+ break;
+ case RZG2L_POEG_OUTPUT_DISABLE_USR_DISABLE_CMD:
+ rzg2l_poeg_output_disable_user(chip, false);
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return len;
+}
+
+static int rzg2l_poeg_chrdev_open(struct inode *inode, struct file *filp)
+{
+ struct rzg2l_poeg_chip *const chip = container_of(inode->i_cdev, typeof(*chip),
+ poeg_cdev);
+
+ filp->private_data = chip;
+
+ return nonseekable_open(inode, filp);
+}
+
+static int rzg2l_poeg_chrdev_release(struct inode *inode, struct file *filp)
+{
+ filp->private_data = NULL;
+
+ return 0;
+}
+
+static const struct file_operations poeg_fops = {
+ .owner = THIS_MODULE,
+ .write = rzg2l_poeg_chrdev_write,
+ .open = rzg2l_poeg_chrdev_open,
+ .release = rzg2l_poeg_chrdev_release,
+};
+
+static bool rzg2l_poeg_get_linked_gpt_channels(struct platform_device *pdev,
+ struct rzg2l_poeg_chip *chip,
+ struct device_node *gpt_np,
+ u8 poeg_id)
+{
+ struct of_phandle_args of_args;
+ bool ret = false;
+ unsigned int i;
+ u32 poeg_grp;
+ int cells;
+ int err;
+
+ cells = of_property_count_u32_elems(gpt_np, "renesas,poegs");
+ if (cells == -EINVAL)
+ return ret;
+
+ for (i = 0 ; i < RZG2L_GPT_MAX_HW_CHANNELS; i++)
+ chip->gpt_channels[i] = RZG2L_GPT_INVALID_CHANNEL;
+
+ cells >>= 1;
+ for (i = 0; i < cells; i++) {
+ err = of_parse_phandle_with_fixed_args(gpt_np, "renesas,poegs",
+ 1, i, &of_args);
+ if (err) {
+ dev_err_probe(&pdev->dev, err,
+ "Failed to parse 'renesas,poegs' property\n");
+ break;
+ }
+
+ if (of_args.args[0] >= RZG2L_GPT_MAX_HW_CHANNELS) {
+ dev_err(&pdev->dev, "Invalid channel %d >= %d\n",
+ of_args.args[0], RZG2L_GPT_MAX_HW_CHANNELS);
+ of_node_put(of_args.np);
+ break;
+ }
+
+ if (!of_property_read_u32(of_args.np, "renesas,poeg-id", &poeg_grp)) {
+ if (poeg_grp == poeg_id) {
+ chip->gpt_channels[of_args.args[0]] = poeg_id;
+ ret = true;
+ }
+ }
+
+ of_node_put(of_args.np);
+ }
+
+ return ret;
+}
+
+static const struct of_device_id rzg2l_poeg_of_table[] = {
+ { .compatible = "renesas,rzg2l-poeg", },
+ { /* Sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, rzg2l_poeg_of_table);
+
+static void rzg2l_poeg_cleanup(void *data)
+{
+ struct rzg2l_poeg_chip *chip = data;
+
+ put_device(chip->gpt_dev);
+}
+
+static int rzg2l_poeg_probe(struct platform_device *pdev)
+{
+ struct platform_device *gpt_pdev = NULL;
+ struct device *dev = &pdev->dev;
+ struct rzg2l_poeg_chip *chip;
+ bool gpt_linked = false;
+ struct device_node *np;
+ struct device *cdev;
+ u32 cfg, val;
+ int ret, irq;
+
+ chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
+ if (!chip)
+ return -ENOMEM;
+
+ if (!of_property_read_u32(dev->of_node, "renesas,poeg-id", &val))
+ chip->index = val;
+
+ if (chip->index > RZG2L_POEG_MAX_INDEX)
+ return -EINVAL;
+
+ np = of_parse_phandle(dev->of_node, "renesas,gpt", 0);
+ if (np)
+ gpt_pdev = of_find_device_by_node(np);
+
+ gpt_linked = rzg2l_poeg_get_linked_gpt_channels(pdev, chip, np, chip->index);
+ of_node_put(np);
+ if (!gpt_pdev || !gpt_linked)
+ return -ENODEV;
+
+ chip->gpt_dev = &gpt_pdev->dev;
+ ret = devm_add_action_or_reset(dev, rzg2l_poeg_cleanup, chip);
+ if (ret < 0)
+ return ret;
+
+ chip->mmio = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(chip->mmio))
+ return PTR_ERR(chip->mmio);
+
+ irq = platform_get_irq(pdev, 0);
+ if (irq < 0)
+ return irq;
+
+ ret = devm_request_irq(dev, irq, rzg2l_poeg_irq, 0, dev_name(dev), chip);
+ if (ret < 0)
+ return dev_err_probe(dev, ret, "cannot get irq\n");
+
+ chip->rstc = devm_reset_control_get_exclusive_deasserted(dev, NULL);
+ if (IS_ERR(chip->rstc))
+ return dev_err_probe(dev, PTR_ERR(chip->rstc), "get deasserted reset failed\n");
+
+ platform_set_drvdata(pdev, chip);
+ ret = devm_pm_runtime_enable(dev);
+ if (ret)
+ return ret;
+
+ ret = pm_runtime_resume_and_get(dev);
+ if (ret < 0)
+ return dev_err_probe(dev, ret, "pm_runtime_resume_get failed\n");
+
+ ret = of_property_read_u32(dev->of_node, "renesas,poeg-config", &cfg);
+ if (ret)
+ goto err_pm;
+
+ switch (cfg) {
+ case POEG_USER_CTRL:
+ rzg2l_poeg_write(chip, 0);
+ break;
+ case POEG_EXT_PIN_CTRL:
+ rzg2l_poeg_write(chip, POEGG_PIDE);
+ break;
+ default:
+ ret = -EINVAL;
+ goto err_pm;
+ }
+
+ chip->cfg = cfg;
+
+ cdev_init(&chip->poeg_cdev, &poeg_fops);
+ chip->poeg_cdev.owner = THIS_MODULE;
+ ret = cdev_add(&chip->poeg_cdev, MKDEV(MAJOR(g_poeg_dev), chip->index), 1);
+ if (ret)
+ goto err_pm;
+
+ cdev = device_create(poeg_class, NULL, MKDEV(MAJOR(g_poeg_dev), chip->index),
+ NULL, "poeg%d", chip->index);
+ if (IS_ERR(cdev)) {
+ ret = PTR_ERR(cdev);
+ dev_err_probe(dev, ret, "Error %d creating device for port\n", chip->index);
+ goto free_cdev;
+ }
+
+ chip->minor_n = chip->index;
+
+ return ret;
+
+free_cdev:
+ cdev_del(&chip->poeg_cdev);
+err_pm:
+ pm_runtime_put(&pdev->dev);
+ return ret;
+}
+
+static void rzg2l_poeg_remove(struct platform_device *pdev)
+{
+ struct rzg2l_poeg_chip *chip = platform_get_drvdata(pdev);
+
+ device_destroy(poeg_class, MKDEV(MAJOR(g_poeg_dev), chip->minor_n));
+ cdev_del(&chip->poeg_cdev);
+ pm_runtime_put(&pdev->dev);
+}
+
+static struct platform_driver rzg2l_poeg_driver = {
+ .driver = {
+ .name = "rzg2l-poeg",
+ .of_match_table = rzg2l_poeg_of_table
+ },
+ .probe = rzg2l_poeg_probe,
+ .remove = rzg2l_poeg_remove
+};
+
+static int rzg2l_poeg_device_init(void)
+{
+ int err;
+
+ err = alloc_chrdev_region(&g_poeg_dev, 0, 1, "poeg");
+ if (err)
+ goto out;
+
+ poeg_class = class_create("poeg");
+ if (IS_ERR(poeg_class)) {
+ err = PTR_ERR(poeg_class);
+ goto err_free_chrdev;
+ }
+
+ err = platform_driver_register(&rzg2l_poeg_driver);
+ if (err)
+ goto err_class_destroy;
+
+ return 0;
+
+err_class_destroy:
+ class_destroy(poeg_class);
+err_free_chrdev:
+ unregister_chrdev_region(g_poeg_dev, 1);
+out:
+ return err;
+}
+
+static void rzg2l_poeg_device_exit(void)
+{
+ platform_driver_unregister(&rzg2l_poeg_driver);
+ class_destroy(poeg_class);
+ unregister_chrdev_region(g_poeg_dev, 1);
+}
+
+module_init(rzg2l_poeg_device_init);
+module_exit(rzg2l_poeg_device_exit);
+
+MODULE_AUTHOR("Biju Das <biju.das.jz@bp.renesas.com>");
+MODULE_DESCRIPTION("Renesas RZ/G2L POEG Driver");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/pinctrl/rzg2l-poeg.h b/include/linux/pinctrl/rzg2l-poeg.h
new file mode 100644
index 000000000000..a5392f956700
--- /dev/null
+++ b/include/linux/pinctrl/rzg2l-poeg.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __LINUX_RENESAS_RZG2L_POEG_H__
+#define __LINUX_RENESAS_RZG2L_POEG_H__
+
+#include <linux/types.h>
+
+#define RZG2L_POEG_OUTPUT_DISABLE_USR_DISABLE_CMD 0
+#define RZG2L_POEG_OUTPUT_DISABLE_USR_ENABLE_CMD 1
+
+struct poeg_cmd {
+ __u32 val;
+ __u8 channel;
+};
+
+#endif /* __LINUX_RENESAS_RZG2L_POEG_H__ */
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH v8 05/15] arm64: dts: renesas: r9a07g0{4,5}4: Add POEG nodes
2025-11-21 16:08 [PATCH v8 00/15] Add RZ/G2L POEG support Biju
` (3 preceding siblings ...)
2025-11-21 16:08 ` [PATCH v8 04/15] drivers: pinctrl: renesas: Add RZ/G2L POEG driver support Biju
@ 2025-11-21 16:08 ` Biju
2025-11-21 16:08 ` [PATCH v8 06/15] arm64: dts: renesas: rzg2l-smarc: Enable POEGG{A,B,C,D} on carrier board Biju
` (10 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Biju @ 2025-11-21 16:08 UTC (permalink / raw)
To: Geert Uytterhoeven, Magnus Damm, Rob Herring, Krzysztof Kozlowski,
Conor Dooley
Cc: Biju Das, linux-renesas-soc, devicetree, linux-kernel,
Prabhakar Mahadev Lad, Biju Das
From: Biju Das <biju.das.jz@bp.renesas.com>
Add POEGG{A,B,C,D} nodes to RZ/{G2L,V2L} SoC DTSI.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v8:
* New patch
---
arch/arm64/boot/dts/renesas/r9a07g044.dtsi | 52 ++++++++++++++++++++++
arch/arm64/boot/dts/renesas/r9a07g054.dtsi | 52 ++++++++++++++++++++++
2 files changed, 104 insertions(+)
diff --git a/arch/arm64/boot/dts/renesas/r9a07g044.dtsi b/arch/arm64/boot/dts/renesas/r9a07g044.dtsi
index bd52d60bafb9..28ef5ac98712 100644
--- a/arch/arm64/boot/dts/renesas/r9a07g044.dtsi
+++ b/arch/arm64/boot/dts/renesas/r9a07g044.dtsi
@@ -359,6 +359,58 @@ gpt: pwm@10048000 {
status = "disabled";
};
+ poegga: poeg@10048800 {
+ compatible = "renesas,r9a07g044-poeg",
+ "renesas,rzg2l-poeg";
+ reg = <0 0x10048800 0 0x400>;
+ interrupts = <GIC_SPI 322 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&cpg CPG_MOD R9A07G044_POEG_A_CLKP>;
+ power-domains = <&cpg>;
+ resets = <&cpg R9A07G044_POEG_A_RST>;
+ renesas,poeg-id = <0>;
+ renesas,gpt = <&gpt>;
+ status = "disabled";
+ };
+
+ poeggb: poeg@10048c00 {
+ compatible = "renesas,r9a07g044-poeg",
+ "renesas,rzg2l-poeg";
+ reg = <0 0x10048c00 0 0x400>;
+ interrupts = <GIC_SPI 323 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&cpg CPG_MOD R9A07G044_POEG_B_CLKP>;
+ power-domains = <&cpg>;
+ resets = <&cpg R9A07G044_POEG_B_RST>;
+ renesas,poeg-id = <1>;
+ renesas,gpt = <&gpt>;
+ status = "disabled";
+ };
+
+ poeggc: poeg@10049000 {
+ compatible = "renesas,r9a07g044-poeg",
+ "renesas,rzg2l-poeg";
+ reg = <0 0x10049000 0 0x400>;
+ interrupts = <GIC_SPI 324 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&cpg CPG_MOD R9A07G044_POEG_C_CLKP>;
+ power-domains = <&cpg>;
+ resets = <&cpg R9A07G044_POEG_C_RST>;
+ renesas,poeg-id = <2>;
+ renesas,gpt = <&gpt>;
+ status = "disabled";
+ };
+
+ poeggd: poeg@10049400 {
+ compatible = "renesas,r9a07g044-poeg",
+ "renesas,rzg2l-poeg";
+ reg = <0 0x10049400 0 0x400>;
+ interrupts = <GIC_SPI 325 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&cpg CPG_MOD R9A07G044_POEG_D_CLKP>;
+ power-domains = <&cpg>;
+ resets = <&cpg R9A07G044_POEG_D_RST>;
+ renesas,poeg-id = <3>;
+ renesas,gpt = <&gpt>;
+ status = "disabled";
+ };
+
ssi0: ssi@10049c00 {
compatible = "renesas,r9a07g044-ssi",
"renesas,rz-ssi";
diff --git a/arch/arm64/boot/dts/renesas/r9a07g054.dtsi b/arch/arm64/boot/dts/renesas/r9a07g054.dtsi
index 4e0256d3201d..14ea99d2cfd0 100644
--- a/arch/arm64/boot/dts/renesas/r9a07g054.dtsi
+++ b/arch/arm64/boot/dts/renesas/r9a07g054.dtsi
@@ -359,6 +359,58 @@ gpt: pwm@10048000 {
status = "disabled";
};
+ poegga: poeg@10048800 {
+ compatible = "renesas,r9a07g054-poeg",
+ "renesas,rzg2l-poeg";
+ reg = <0 0x10048800 0 0x400>;
+ interrupts = <GIC_SPI 322 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&cpg CPG_MOD R9A07G054_POEG_A_CLKP>;
+ power-domains = <&cpg>;
+ resets = <&cpg R9A07G054_POEG_A_RST>;
+ renesas,poeg-id = <0>;
+ renesas,gpt = <&gpt>;
+ status = "disabled";
+ };
+
+ poeggb: poeg@10048c00 {
+ compatible = "renesas,r9a07g054-poeg",
+ "renesas,rzg2l-poeg";
+ reg = <0 0x10048c00 0 0x400>;
+ interrupts = <GIC_SPI 323 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&cpg CPG_MOD R9A07G054_POEG_B_CLKP>;
+ power-domains = <&cpg>;
+ resets = <&cpg R9A07G054_POEG_B_RST>;
+ renesas,poeg-id = <1>;
+ renesas,gpt = <&gpt>;
+ status = "disabled";
+ };
+
+ poeggc: poeg@10049000 {
+ compatible = "renesas,r9a07g054-poeg",
+ "renesas,rzg2l-poeg";
+ reg = <0 0x10049000 0 0x400>;
+ interrupts = <GIC_SPI 324 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&cpg CPG_MOD R9A07G054_POEG_C_CLKP>;
+ power-domains = <&cpg>;
+ resets = <&cpg R9A07G054_POEG_C_RST>;
+ renesas,poeg-id = <2>;
+ renesas,gpt = <&gpt>;
+ status = "disabled";
+ };
+
+ poeggd: poeg@10049400 {
+ compatible = "renesas,r9a07g054-poeg",
+ "renesas,rzg2l-poeg";
+ reg = <0 0x10049400 0 0x400>;
+ interrupts = <GIC_SPI 325 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&cpg CPG_MOD R9A07G054_POEG_D_CLKP>;
+ power-domains = <&cpg>;
+ resets = <&cpg R9A07G054_POEG_D_RST>;
+ renesas,poeg-id = <3>;
+ renesas,gpt = <&gpt>;
+ status = "disabled";
+ };
+
ssi0: ssi@10049c00 {
compatible = "renesas,r9a07g054-ssi",
"renesas,rz-ssi";
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH v8 06/15] arm64: dts: renesas: rzg2l-smarc: Enable POEGG{A,B,C,D} on carrier board
2025-11-21 16:08 [PATCH v8 00/15] Add RZ/G2L POEG support Biju
` (4 preceding siblings ...)
2025-11-21 16:08 ` [PATCH v8 05/15] arm64: dts: renesas: r9a07g0{4,5}4: Add POEG nodes Biju
@ 2025-11-21 16:08 ` Biju
2025-11-21 16:08 ` [PATCH v8 07/15] arm64: defconfig: Enable Renesas RZ/G2L POEG interface Biju
` (9 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Biju @ 2025-11-21 16:08 UTC (permalink / raw)
To: Geert Uytterhoeven, Magnus Damm, Rob Herring, Krzysztof Kozlowski,
Conor Dooley
Cc: Biju Das, linux-renesas-soc, devicetree, linux-kernel,
Prabhakar Mahadev Lad, Biju Das
From: Biju Das <biju.das.jz@bp.renesas.com>
Enable POEGG{A,B,C,D} on RZ/{G2,V2}L SMARC EVK.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v8:
* New patch.
---
arch/arm64/boot/dts/renesas/rzg2l-smarc.dtsi | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/arm64/boot/dts/renesas/rzg2l-smarc.dtsi b/arch/arm64/boot/dts/renesas/rzg2l-smarc.dtsi
index b76b55e7f09d..7648f0e96668 100644
--- a/arch/arm64/boot/dts/renesas/rzg2l-smarc.dtsi
+++ b/arch/arm64/boot/dts/renesas/rzg2l-smarc.dtsi
@@ -109,6 +109,7 @@ &gpt {
pinctrl-0 = <&gpt_pins>;
pinctrl-names = "default";
status = "okay";
+ renesas,poegs = <&poeggd 4>;
};
#endif /* PMOD0_GPT */
@@ -166,6 +167,11 @@ &spi1 {
};
#endif /* PMOD_MTU3 */
+&poeggd {
+ status = "okay";
+ renesas,poeg-config = <1>;
+};
+
/*
* To enable SCIF2 (SER0) on PMOD1 (CN7)
* SW1 should be at position 2->3 so that SER0_CTS# line is activated
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH v8 07/15] arm64: defconfig: Enable Renesas RZ/G2L POEG interface
2025-11-21 16:08 [PATCH v8 00/15] Add RZ/G2L POEG support Biju
` (5 preceding siblings ...)
2025-11-21 16:08 ` [PATCH v8 06/15] arm64: dts: renesas: rzg2l-smarc: Enable POEGG{A,B,C,D} on carrier board Biju
@ 2025-11-21 16:08 ` Biju
2025-11-21 16:08 ` [DO NOT APPLY PATCH v8 08/15] tools/poeg: Add test app for poeg Biju
` (8 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Biju @ 2025-11-21 16:08 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Biju Das, Krzysztof Kozlowski, Bjorn Andersson, Arnd Bergmann,
Dmitry Baryshkov, Eric Biggers, Michal Simek, Luca Weiss,
Nícolas F. R. A. Prado, Lad Prabhakar, Kuninori Morimoto,
linux-kernel, Biju Das, linux-renesas-soc
From: Biju Das <biju.das.jz@bp.renesas.com>
The Renesas RZ/G2L POEG interface is used in SMARC RZ/G2L EVK.
Enable the driver for it in the default configuration.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v8:
* New patch.
---
arch/arm64/configs/defconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index dcdd4fcdc2a7..f2c28deb2283 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -688,6 +688,7 @@ CONFIG_PINCTRL_SM8450_LPASS_LPI=m
CONFIG_PINCTRL_SC8280XP_LPASS_LPI=m
CONFIG_PINCTRL_SM8550_LPASS_LPI=m
CONFIG_PINCTRL_SM8650_LPASS_LPI=m
+CONFIG_RENESAS_RZG2L_POEG=m
CONFIG_PINCTRL_SOPHGO_SG2000=y
CONFIG_GPIO_ALTERA=m
CONFIG_GPIO_DAVINCI=y
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread* [DO NOT APPLY PATCH v8 08/15] tools/poeg: Add test app for poeg
2025-11-21 16:08 [PATCH v8 00/15] Add RZ/G2L POEG support Biju
` (6 preceding siblings ...)
2025-11-21 16:08 ` [PATCH v8 07/15] arm64: defconfig: Enable Renesas RZ/G2L POEG interface Biju
@ 2025-11-21 16:08 ` Biju
2025-11-21 16:08 ` [DO NOT APPLY v8 09/15] pwm: rzg2l-gpt: Add support for output disable request from gpt Biju
` (7 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Biju @ 2025-11-21 16:08 UTC (permalink / raw)
To: Uwe Kleine-König, Geert Uytterhoeven, Linus Walleij
Cc: Biju Das, linux-kernel, linux-pwm, Prabhakar Mahadev Lad,
Biju Das, linux-renesas-soc, linux-gpio
From: Biju Das <biju.das.jz@bp.renesas.com>
Add test app for poeg for controlling output disable through
user space.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
tools/poeg/Build | 1 +
tools/poeg/Makefile | 53 +++++++++++++++++++++++++++++++++++++++
tools/poeg/poeg_app.c | 58 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 112 insertions(+)
create mode 100644 tools/poeg/Build
create mode 100644 tools/poeg/Makefile
create mode 100644 tools/poeg/poeg_app.c
diff --git a/tools/poeg/Build b/tools/poeg/Build
new file mode 100644
index 000000000000..f960920a4afb
--- /dev/null
+++ b/tools/poeg/Build
@@ -0,0 +1 @@
+poeg_app-y += poeg_app.o
diff --git a/tools/poeg/Makefile b/tools/poeg/Makefile
new file mode 100644
index 000000000000..669c914d9c98
--- /dev/null
+++ b/tools/poeg/Makefile
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: GPL-2.0
+include ../scripts/Makefile.include
+
+bindir ?= /usr/bin
+
+ifeq ($(srctree),)
+srctree := $(patsubst %/,%,$(dir $(CURDIR)))
+srctree := $(patsubst %/,%,$(dir $(srctree)))
+endif
+
+# Do not use make's built-in rules
+# (this improves performance and avoids hard-to-debug behaviour);
+MAKEFLAGS += -r
+
+override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
+
+ALL_TARGETS := poeg_app
+ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
+
+all: $(ALL_PROGRAMS)
+
+export srctree OUTPUT CC LD CFLAGS
+include $(srctree)/tools/build/Makefile.include
+
+#
+# We need the following to be outside of kernel tree
+#
+$(OUTPUT)include/linux/poeg.h: ../../include/linux/pinctrl/rzg2l-poeg.h
+ mkdir -p $(OUTPUT)include/linux 2>&1 || true
+ ln -sf $(CURDIR)/../../include/linux/pinctrl/rzg2l-poeg.h $@
+
+prepare: $(OUTPUT)include/linux/poeg.h
+
+POEG_EXAMPLE := $(OUTPUT)poeg_app.o
+$(POEG_EXAMPLE): prepare FORCE
+ $(Q)$(MAKE) $(build)=poeg_app
+$(OUTPUT)poeg_app: $(POEG_EXAMPLE)
+ $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
+
+clean:
+ rm -f $(ALL_PROGRAMS)
+ rm -rf $(OUTPUT)include/linux/poeg.h
+ find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
+
+install: $(ALL_PROGRAMS)
+ install -d -m 755 $(DESTDIR)$(bindir); \
+ for program in $(ALL_PROGRAMS); do \
+ install $$program $(DESTDIR)$(bindir); \
+ done
+
+FORCE:
+
+.PHONY: all install clean FORCE prepare
diff --git a/tools/poeg/poeg_app.c b/tools/poeg/poeg_app.c
new file mode 100644
index 000000000000..4ff8e5c007dc
--- /dev/null
+++ b/tools/poeg/poeg_app.c
@@ -0,0 +1,58 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * POEG - example userspace application
+ * Copyright (C) 2023 Biju Das
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/ioctl.h>
+#include <linux/ioctl.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <poll.h>
+
+#include <linux/poeg.h>
+
+int main(int argc, char *argv[])
+{
+ struct poeg_cmd cmd;
+ unsigned int val;
+ long cmd_val;
+ char *p;
+ int i;
+
+ cmd_val = strtol(argv[1], &p, 10);
+ if (*p != '\0' || errno != 0)
+ return 1; // In main(), returning non-zero means failure
+
+ fd = open("/dev/poeg3", O_RDWR);
+ if (fd < 0)
+ perror("open");
+ else
+ printf("[POEG]open\n");
+
+ cmd.val = cmd_val;
+ cmd.channel = 4;
+ if (cmd.val == RZG2L_POEG_OUTPUT_DISABLE_USR_ENABLE_CMD)
+ printf("[POEG] user control pin output disable enabled\n");
+ else
+ printf("[POEG] user control pin output disable disabled\n");
+
+ ret = write(fd, &cmd, sizeof(cmd));
+ if (ret == -1) {
+ perror("Failed to write cmd data");
+ return 1;
+ }
+
+ if (close(fd) != 0)
+ perror("close");
+ else
+ printf("[POEG]close\n");
+
+ return 0;
+}
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread* [DO NOT APPLY v8 09/15] pwm: rzg2l-gpt: Add support for output disable request from gpt
2025-11-21 16:08 [PATCH v8 00/15] Add RZ/G2L POEG support Biju
` (7 preceding siblings ...)
2025-11-21 16:08 ` [DO NOT APPLY PATCH v8 08/15] tools/poeg: Add test app for poeg Biju
@ 2025-11-21 16:08 ` Biju
2025-11-21 16:08 ` [DO NOT APPLY PATCH v8 10/15] pwm: rzg2l-gpt: Add support for output disable when both output low Biju
` (6 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Biju @ 2025-11-21 16:08 UTC (permalink / raw)
To: Uwe Kleine-König, Geert Uytterhoeven, Linus Walleij
Cc: Biju Das, linux-kernel, linux-pwm, Prabhakar Mahadev Lad,
Biju Das, linux-renesas-soc, linux-gpio
From: Biju Das <biju.das.jz@bp.renesas.com>
When dead time error occurs or the GTIOCA pin output value is
the same as the GTIOCB pin output value, output protection is
required. GPT detects this condition and generates output disable
requests to POEG based on the settings in the output disable request
permission bits, such as GTINTAD.GRPDTE, GTINTAD.GRPABH,
GTINTAD.GRPABL. After the POEG receives output disable requests from
each channel and calculates external input using an OR operation, the
POEG generates output disable requests to GPT.
Add support for output disable request from gpt, when output level is
high for both IOs at the same time.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
drivers/pwm/pwm-rzg2l-gpt.c | 99 +++++++++++++++++++++++++++++++++++
include/linux/pwm/rzg2l-gpt.h | 33 ++++++++++++
2 files changed, 132 insertions(+)
create mode 100644 include/linux/pwm/rzg2l-gpt.h
diff --git a/drivers/pwm/pwm-rzg2l-gpt.c b/drivers/pwm/pwm-rzg2l-gpt.c
index aabd2d576231..8006c62068b6 100644
--- a/drivers/pwm/pwm-rzg2l-gpt.c
+++ b/drivers/pwm/pwm-rzg2l-gpt.c
@@ -29,6 +29,7 @@
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pwm.h>
+#include <linux/pwm/rzg2l-gpt.h>
#include <linux/reset.h>
#include <linux/time.h>
#include <linux/units.h>
@@ -40,6 +41,7 @@
#define RZG2L_GTUDDTYC(ch) (0x30 + RZG2L_GET_CH_OFFS(ch))
#define RZG2L_GTIOR(ch) (0x34 + RZG2L_GET_CH_OFFS(ch))
#define RZG2L_GTINTAD(ch) (0x38 + RZG2L_GET_CH_OFFS(ch))
+#define RZG2L_GTST(ch) (0x3c + RZG2L_GET_CH_OFFS(ch))
#define RZG2L_GTBER(ch) (0x40 + RZG2L_GET_CH_OFFS(ch))
#define RZG2L_GTCNT(ch) (0x48 + RZG2L_GET_CH_OFFS(ch))
#define RZG2L_GTCCR(ch, sub_ch) (0x4c + RZG2L_GET_CH_OFFS(ch) + 4 * (sub_ch))
@@ -82,6 +84,12 @@
RZG2L_GTIOR_GTIOA_OUT_HI_END_TOGGLE_CMP_MATCH)
#define RZG2L_GTINTAD_GRP_MASK GENMASK(25, 24)
+#define RZG2L_GTINTAD_OUTPUT_DISABLE_SAME_LEVEL_HIGH BIT(29)
+
+#define RZG2L_GTST_OABHF BIT(29)
+#define RZG2L_GTST_OABLF BIT(30)
+
+#define RZG2L_GTST_POEG_IRQ_MASK GENMASK(30, 28)
#define RZG2L_MAX_HW_CHANNELS 8
#define RZG2L_CHANNELS_PER_IO 2
@@ -395,6 +403,96 @@ static const struct pwm_ops rzg2l_gpt_ops = {
.apply = rzg2l_gpt_apply,
};
+u32 rzg2l_gpt_poeg_disable_req_irq_status(void *dev, u8 grp)
+{
+ struct rzg2l_gpt_chip *rzg2l_gpt = dev_get_drvdata(dev);
+ u8 bitpos = grp * RZG2L_MAX_HW_CHANNELS;
+ unsigned int i;
+ u8 irq_bitpos;
+ u32 irq_bits;
+ u32 val = 0;
+ u32 reg;
+
+ for (i = 0; i < RZG2L_MAX_HW_CHANNELS; i++) {
+ if (!test_bit(bitpos + i, rzg2l_gpt->poeg_gpt_link))
+ continue;
+ else
+ irq_bitpos = (3 * i);
+
+ reg = rzg2l_gpt_read(rzg2l_gpt, RZG2L_GTST(i));
+ irq_bits = FIELD_GET(RZG2L_GTST_POEG_IRQ_MASK, reg);
+ val |= (irq_bits << irq_bitpos);
+ }
+
+ return val;
+}
+EXPORT_SYMBOL_GPL(rzg2l_gpt_poeg_disable_req_irq_status);
+
+int rzg2l_gpt_poeg_disable_req_clr(void *dev, u8 grp)
+{
+ struct rzg2l_gpt_chip *rzg2l_gpt = dev_get_drvdata(dev);
+ u8 bitpos = grp * RZG2L_MAX_HW_CHANNELS;
+ unsigned int i;
+ u32 reg;
+
+ for (i = 0; i < RZG2L_MAX_HW_CHANNELS; i++) {
+ if (!test_bit(bitpos + i, rzg2l_gpt->poeg_gpt_link))
+ continue;
+
+ reg = rzg2l_gpt_read(rzg2l_gpt, RZG2L_GTST(i));
+ if (reg & (RZG2L_GTST_OABHF | RZG2L_GTST_OABLF))
+ rzg2l_gpt_modify(rzg2l_gpt, RZG2L_GTIOR(i),
+ RZG2L_GTIOR_OBE, 0);
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(rzg2l_gpt_poeg_disable_req_clr);
+
+int rzg2l_gpt_pin_reenable(void *dev, u8 grp)
+{
+ struct rzg2l_gpt_chip *rzg2l_gpt = dev_get_drvdata(dev);
+ u8 bitpos = grp * RZG2L_MAX_HW_CHANNELS;
+ unsigned int i;
+
+ for (i = 0; i < RZG2L_MAX_HW_CHANNELS; i++) {
+ if (!test_bit(bitpos + i, rzg2l_gpt->poeg_gpt_link))
+ continue;
+
+ rzg2l_gpt_modify(rzg2l_gpt, RZG2L_GTIOR(i),
+ RZG2L_GTIOR_OBE, RZG2L_GTIOR_OBE);
+ }
+ return 0;
+}
+EXPORT_SYMBOL_GPL(rzg2l_gpt_pin_reenable);
+
+static int rzg2l_gpt_poeg_disable_req_endisable(void *dev, u8 grp, int op, bool on)
+{
+ struct rzg2l_gpt_chip *rzg2l_gpt = dev_get_drvdata(dev);
+ u8 bitpos = grp * RZG2L_MAX_HW_CHANNELS;
+ unsigned int i;
+
+ for (i = 0; i < RZG2L_MAX_HW_CHANNELS; i++) {
+ if (!test_bit(bitpos + i, rzg2l_gpt->poeg_gpt_link))
+ continue;
+
+ if (on)
+ rzg2l_gpt_modify(rzg2l_gpt, RZG2L_GTINTAD(i), op, op);
+ else
+ rzg2l_gpt_modify(rzg2l_gpt, RZG2L_GTINTAD(i), op, 0);
+ }
+
+ return 0;
+}
+
+int rzg2l_gpt_poeg_disable_req_both_high(void *dev, u8 grp, bool on)
+{
+ int id = RZG2L_GTINTAD_OUTPUT_DISABLE_SAME_LEVEL_HIGH;
+
+ return rzg2l_gpt_poeg_disable_req_endisable(dev, grp, id, on);
+}
+EXPORT_SYMBOL_GPL(rzg2l_gpt_poeg_disable_req_both_high);
+
/*
* This function links a poeg group{A,B,C,D} with a gpt channel{0..7} and
* configure the pin for output disable.
@@ -526,6 +624,7 @@ static int rzg2l_gpt_probe(struct platform_device *pdev)
return dev_err_probe(dev, ret, "Failed to link gpt with poeg\n");
mutex_init(&rzg2l_gpt->lock);
+ platform_set_drvdata(pdev, rzg2l_gpt);
chip->ops = &rzg2l_gpt_ops;
ret = devm_pwmchip_add(dev, chip);
diff --git a/include/linux/pwm/rzg2l-gpt.h b/include/linux/pwm/rzg2l-gpt.h
new file mode 100644
index 000000000000..718aaeca39f2
--- /dev/null
+++ b/include/linux/pwm/rzg2l-gpt.h
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __LINUX_PWM_RENESAS_RZG2L_GPT_H__
+#define __LINUX_PWM_RENESAS_RZG2L_GPT_H__
+
+#if IS_ENABLED(CONFIG_PWM_RENESAS_RZG2L_GPT)
+u32 rzg2l_gpt_poeg_disable_req_irq_status(void *dev, u8 grp);
+int rzg2l_gpt_poeg_disable_req_clr(void *gpt_device, u8 grp);
+int rzg2l_gpt_pin_reenable(void *gpt_device, u8 grp);
+int rzg2l_gpt_poeg_disable_req_both_high(void *gpt_device, u8 grp, bool on);
+#else
+static inline u32 rzg2l_gpt_poeg_disable_req_irq_status(void *dev, u8 grp)
+{
+ return -ENODEV;
+}
+
+static inline int rzg2l_gpt_poeg_disable_req_clr(void *gpt_device, u8 grp)
+{
+ return -ENODEV;
+}
+
+static inline int rzg2l_gpt_pin_reenable(void *gpt_device, u8 grp)
+{
+ return -ENODEV;
+}
+
+static inline int rzg2l_gpt_poeg_disable_req_both_high(void *gpt_device, u8 grp, bool on)
+{
+ return -ENODEV;
+}
+
+#endif
+
+#endif /* __LINUX_PWM_RENESAS_RZG2L_GPT_H__ */
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread* [DO NOT APPLY PATCH v8 10/15] pwm: rzg2l-gpt: Add support for output disable when both output low
2025-11-21 16:08 [PATCH v8 00/15] Add RZ/G2L POEG support Biju
` (8 preceding siblings ...)
2025-11-21 16:08 ` [DO NOT APPLY v8 09/15] pwm: rzg2l-gpt: Add support for output disable request from gpt Biju
@ 2025-11-21 16:08 ` Biju
2025-11-21 16:08 ` [DO NOT APPLY PATCH v8 11/15] pwm: rzg2l-gpt: Add support for output disable on dead time error Biju
` (5 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Biju @ 2025-11-21 16:08 UTC (permalink / raw)
To: Uwe Kleine-König, Geert Uytterhoeven, Linus Walleij
Cc: Biju Das, linux-kernel, linux-pwm, Prabhakar Mahadev Lad,
Biju Das, linux-renesas-soc, linux-gpio
From: Biju Das <biju.das.jz@bp.renesas.com>
This patch adds support for output disable request from gpt,
when same time output level is low.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
drivers/pwm/pwm-rzg2l-gpt.c | 9 +++++++++
include/linux/pwm/rzg2l-gpt.h | 6 ++++++
2 files changed, 15 insertions(+)
diff --git a/drivers/pwm/pwm-rzg2l-gpt.c b/drivers/pwm/pwm-rzg2l-gpt.c
index 8006c62068b6..a0100e1b948d 100644
--- a/drivers/pwm/pwm-rzg2l-gpt.c
+++ b/drivers/pwm/pwm-rzg2l-gpt.c
@@ -85,6 +85,7 @@
#define RZG2L_GTINTAD_GRP_MASK GENMASK(25, 24)
#define RZG2L_GTINTAD_OUTPUT_DISABLE_SAME_LEVEL_HIGH BIT(29)
+#define RZG2L_GTINTAD_OUTPUT_DISABLE_SAME_LEVEL_LOW BIT(30)
#define RZG2L_GTST_OABHF BIT(29)
#define RZG2L_GTST_OABLF BIT(30)
@@ -493,6 +494,14 @@ int rzg2l_gpt_poeg_disable_req_both_high(void *dev, u8 grp, bool on)
}
EXPORT_SYMBOL_GPL(rzg2l_gpt_poeg_disable_req_both_high);
+int rzg2l_gpt_poeg_disable_req_both_low(void *dev, u8 grp, bool on)
+{
+ int id = RZG2L_GTINTAD_OUTPUT_DISABLE_SAME_LEVEL_LOW;
+
+ return rzg2l_gpt_poeg_disable_req_endisable(dev, grp, id, on);
+}
+EXPORT_SYMBOL_GPL(rzg2l_gpt_poeg_disable_req_both_low);
+
/*
* This function links a poeg group{A,B,C,D} with a gpt channel{0..7} and
* configure the pin for output disable.
diff --git a/include/linux/pwm/rzg2l-gpt.h b/include/linux/pwm/rzg2l-gpt.h
index 718aaeca39f2..adb5b9cfc8b3 100644
--- a/include/linux/pwm/rzg2l-gpt.h
+++ b/include/linux/pwm/rzg2l-gpt.h
@@ -7,6 +7,7 @@ u32 rzg2l_gpt_poeg_disable_req_irq_status(void *dev, u8 grp);
int rzg2l_gpt_poeg_disable_req_clr(void *gpt_device, u8 grp);
int rzg2l_gpt_pin_reenable(void *gpt_device, u8 grp);
int rzg2l_gpt_poeg_disable_req_both_high(void *gpt_device, u8 grp, bool on);
+int rzg2l_gpt_poeg_disable_req_both_low(void *gpt_device, u8 grp, bool on);
#else
static inline u32 rzg2l_gpt_poeg_disable_req_irq_status(void *dev, u8 grp)
{
@@ -28,6 +29,11 @@ static inline int rzg2l_gpt_poeg_disable_req_both_high(void *gpt_device, u8 grp,
return -ENODEV;
}
+static inline int rzg2l_gpt_poeg_disable_req_both_low(void *gpt_device, u8 grp, bool on)
+{
+ return -ENODEV;
+}
+
#endif
#endif /* __LINUX_PWM_RENESAS_RZG2L_GPT_H__ */
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread* [DO NOT APPLY PATCH v8 11/15] pwm: rzg2l-gpt: Add support for output disable on dead time error
2025-11-21 16:08 [PATCH v8 00/15] Add RZ/G2L POEG support Biju
` (9 preceding siblings ...)
2025-11-21 16:08 ` [DO NOT APPLY PATCH v8 10/15] pwm: rzg2l-gpt: Add support for output disable when both output low Biju
@ 2025-11-21 16:08 ` Biju
2025-11-21 16:08 ` [DO NOT APPLY PATCH v8 12/15] pinctrl: renesas: rzg2l-poeg: Add support for GPT Output-Disable Request Biju
` (4 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Biju @ 2025-11-21 16:08 UTC (permalink / raw)
To: Uwe Kleine-König, Geert Uytterhoeven, Linus Walleij
Cc: Biju Das, linux-kernel, linux-pwm, Prabhakar Mahadev Lad,
Biju Das, linux-renesas-soc, linux-gpio
From: Biju Das <biju.das.jz@bp.renesas.com>
This patch adds support for output disable request from gpt,
when dead time error occurred.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
drivers/pwm/pwm-rzg2l-gpt.c | 9 +++++++++
include/linux/pwm/rzg2l-gpt.h | 5 +++++
2 files changed, 14 insertions(+)
diff --git a/drivers/pwm/pwm-rzg2l-gpt.c b/drivers/pwm/pwm-rzg2l-gpt.c
index a0100e1b948d..0e158f677f01 100644
--- a/drivers/pwm/pwm-rzg2l-gpt.c
+++ b/drivers/pwm/pwm-rzg2l-gpt.c
@@ -84,6 +84,7 @@
RZG2L_GTIOR_GTIOA_OUT_HI_END_TOGGLE_CMP_MATCH)
#define RZG2L_GTINTAD_GRP_MASK GENMASK(25, 24)
+#define RZG2L_GTINTAD_OUTPUT_DISABLE_DEADTIME_ERROR BIT(28)
#define RZG2L_GTINTAD_OUTPUT_DISABLE_SAME_LEVEL_HIGH BIT(29)
#define RZG2L_GTINTAD_OUTPUT_DISABLE_SAME_LEVEL_LOW BIT(30)
@@ -502,6 +503,14 @@ int rzg2l_gpt_poeg_disable_req_both_low(void *dev, u8 grp, bool on)
}
EXPORT_SYMBOL_GPL(rzg2l_gpt_poeg_disable_req_both_low);
+int rzg2l_gpt_poeg_disable_req_deadtime_error(void *dev, u8 grp, bool on)
+{
+ int id = RZG2L_GTINTAD_OUTPUT_DISABLE_DEADTIME_ERROR;
+
+ return rzg2l_gpt_poeg_disable_req_endisable(dev, grp, id, on);
+}
+EXPORT_SYMBOL_GPL(rzg2l_gpt_poeg_disable_req_deadtime_error);
+
/*
* This function links a poeg group{A,B,C,D} with a gpt channel{0..7} and
* configure the pin for output disable.
diff --git a/include/linux/pwm/rzg2l-gpt.h b/include/linux/pwm/rzg2l-gpt.h
index adb5b9cfc8b3..f9365bbca57c 100644
--- a/include/linux/pwm/rzg2l-gpt.h
+++ b/include/linux/pwm/rzg2l-gpt.h
@@ -8,6 +8,7 @@ int rzg2l_gpt_poeg_disable_req_clr(void *gpt_device, u8 grp);
int rzg2l_gpt_pin_reenable(void *gpt_device, u8 grp);
int rzg2l_gpt_poeg_disable_req_both_high(void *gpt_device, u8 grp, bool on);
int rzg2l_gpt_poeg_disable_req_both_low(void *gpt_device, u8 grp, bool on);
+int rzg2l_gpt_poeg_disable_req_deadtime_error(void *gpt_device, u8 grp, bool on);
#else
static inline u32 rzg2l_gpt_poeg_disable_req_irq_status(void *dev, u8 grp)
{
@@ -34,6 +35,10 @@ static inline int rzg2l_gpt_poeg_disable_req_both_low(void *gpt_device, u8 grp,
return -ENODEV;
}
+static inline int rzg2l_gpt_poeg_disable_req_deadtime_err(void *gpt_device, u8 grp, bool on)
+{
+ return -ENODEV;
+}
#endif
#endif /* __LINUX_PWM_RENESAS_RZG2L_GPT_H__ */
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread* [DO NOT APPLY PATCH v8 12/15] pinctrl: renesas: rzg2l-poeg: Add support for GPT Output-Disable Request
2025-11-21 16:08 [PATCH v8 00/15] Add RZ/G2L POEG support Biju
` (10 preceding siblings ...)
2025-11-21 16:08 ` [DO NOT APPLY PATCH v8 11/15] pwm: rzg2l-gpt: Add support for output disable on dead time error Biju
@ 2025-11-21 16:08 ` Biju
2025-11-21 16:08 ` [DO NOT APPLY PATCH v8 13/15] pinctrl: renesas: rzg2l-poeg: output-disable request from GPT when both outputs are low Biju
` (3 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Biju @ 2025-11-21 16:08 UTC (permalink / raw)
To: Uwe Kleine-König, Geert Uytterhoeven, Linus Walleij
Cc: Biju Das, linux-kernel, linux-pwm, Prabhakar Mahadev Lad,
Biju Das, linux-renesas-soc, linux-gpio
From: Biju Das <biju.das.jz@bp.renesas.com>
Add support for output-disable requests from GPT.
When both outputs are high, gpt detects the condition and triggers
an interrupt to POEG. POEG handles the interrupt and send notification
to userspace. userspace handles the fault and issue a write call to
cancel the disable output request.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
drivers/pinctrl/renesas/poeg/rzg2l-poeg.c | 86 ++++++++++++++++++++++-
include/linux/pinctrl/rzg2l-poeg.h | 9 +++
2 files changed, 94 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/renesas/poeg/rzg2l-poeg.c b/drivers/pinctrl/renesas/poeg/rzg2l-poeg.c
index 2a09888407d0..3dd8bc3465b1 100644
--- a/drivers/pinctrl/renesas/poeg/rzg2l-poeg.c
+++ b/drivers/pinctrl/renesas/poeg/rzg2l-poeg.c
@@ -14,6 +14,7 @@
#include <linux/pinctrl/rzg2l-poeg.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
+#include <linux/pwm/rzg2l-gpt.h>
#include <linux/pinctrl/rzg2l-poeg.h>
#include <linux/poll.h>
#include <linux/reset.h>
@@ -49,7 +50,10 @@ struct rzg2l_poeg_chip {
struct device *gpt_dev;
struct reset_control *rstc;
void __iomem *mmio;
+ DECLARE_BITMAP(gpt_irq, 3);
struct cdev poeg_cdev;
+ wait_queue_head_t events_wait;
+ DECLARE_KFIFO_PTR(events, struct poeg_event);
u32 cfg;
int minor_n;
u8 gpt_channels[RZG2L_GPT_MAX_HW_CHANNELS];
@@ -81,12 +85,29 @@ static int rzg2l_poeg_output_disable_user(struct rzg2l_poeg_chip *chip, bool ena
return 0;
}
+static void rzg2l_poeg_config_irq(struct rzg2l_poeg_chip *chip)
+{
+ if (test_bit(RZG2L_GPT_OABHF, chip->gpt_irq))
+ rzg2l_gpt_poeg_disable_req_both_high(chip->gpt_dev, chip->index, true);
+}
+
static irqreturn_t rzg2l_poeg_irq(int irq, void *ptr)
{
struct rzg2l_poeg_chip *chip = ptr;
+ struct poeg_event ev;
u32 val;
+ val = rzg2l_gpt_poeg_disable_req_irq_status(chip->gpt_dev, chip->index);
+ ev.channel = chip->index;
+ ev.gpt_disable_irq_status = val;
+ kfifo_in(&chip->events, &ev, 1);
+ wake_up_poll(&chip->events_wait, EPOLLIN);
+
+ rzg2l_gpt_poeg_disable_req_clr(chip->gpt_dev, chip->index);
val = rzg2l_poeg_read(chip);
+ if (val & POEGG_IOCF)
+ val &= ~POEGG_IOCF;
+
if (val & POEGG_PIDF)
val &= ~POEGG_PIDF;
@@ -95,7 +116,50 @@ static irqreturn_t rzg2l_poeg_irq(int irq, void *ptr)
return IRQ_HANDLED;
}
-static ssize_t rzg2l_poeg_chrdev_write(struct file *filp, const char __user *buf,
+static __poll_t rzg2l_poeg_chrdev_poll(struct file *filp,
+ struct poll_table_struct *pollt)
+{
+ struct rzg2l_poeg_chip *const chip = filp->private_data;
+ __poll_t events = 0;
+
+ poll_wait(filp, &chip->events_wait, pollt);
+ if (!kfifo_is_empty(&chip->events))
+ events = EPOLLIN | EPOLLRDNORM;
+
+ return events;
+}
+
+static ssize_t rzg2l_poeg_chrdev_read(struct file *filp, char __user *buf,
+ size_t len, loff_t *f_ps)
+{
+ struct rzg2l_poeg_chip *const chip = filp->private_data;
+ unsigned int copied;
+ int err;
+
+ if (len < sizeof(struct poeg_event))
+ return -EINVAL;
+
+ do {
+ if (kfifo_is_empty(&chip->events)) {
+ if (filp->f_flags & O_NONBLOCK)
+ return -EAGAIN;
+
+ err = wait_event_interruptible(chip->events_wait,
+ !kfifo_is_empty(&chip->events));
+ if (err < 0)
+ return err;
+ }
+
+ err = kfifo_to_user(&chip->events, buf, len, &copied);
+ if (err < 0)
+ return err;
+ } while (!copied);
+
+ return copied;
+}
+
+static ssize_t rzg2l_poeg_chrdev_write(struct file *filp,
+ const char __user *buf,
size_t len, loff_t *f_ps)
{
struct rzg2l_poeg_chip *const chip = filp->private_data;
@@ -111,6 +175,12 @@ static ssize_t rzg2l_poeg_chrdev_write(struct file *filp, const char __user *buf
case RZG2L_POEG_OUTPUT_DISABLE_USR_DISABLE_CMD:
rzg2l_poeg_output_disable_user(chip, false);
break;
+ case RZG2L_POEG_GPT_CFG_IRQ_CMD:
+ rzg2l_poeg_config_irq(chip);
+ break;
+ case RZG2L_POEG_GPT_FAULT_CLR_CMD:
+ rzg2l_gpt_pin_reenable(chip->gpt_dev, chip->index);
+ break;
default:
return -EINVAL;
}
@@ -137,7 +207,9 @@ static int rzg2l_poeg_chrdev_release(struct inode *inode, struct file *filp)
static const struct file_operations poeg_fops = {
.owner = THIS_MODULE,
+ .read = rzg2l_poeg_chrdev_read,
.write = rzg2l_poeg_chrdev_write,
+ .poll = rzg2l_poeg_chrdev_poll,
.open = rzg2l_poeg_chrdev_open,
.release = rzg2l_poeg_chrdev_release,
};
@@ -272,6 +344,9 @@ static int rzg2l_poeg_probe(struct platform_device *pdev)
case POEG_USER_CTRL:
rzg2l_poeg_write(chip, 0);
break;
+ case POEG_GPT_BOTH_HIGH:
+ assign_bit(RZG2L_GPT_OABHF, chip->gpt_irq, true);
+ break;
case POEG_EXT_PIN_CTRL:
rzg2l_poeg_write(chip, POEGG_PIDE);
break;
@@ -280,8 +355,12 @@ static int rzg2l_poeg_probe(struct platform_device *pdev)
goto err_pm;
}
+ if (cfg & POEG_GPT_ALL)
+ rzg2l_poeg_write(chip, POEGG_IOCE);
+
chip->cfg = cfg;
+ init_waitqueue_head(&chip->events_wait);
cdev_init(&chip->poeg_cdev, &poeg_fops);
chip->poeg_cdev.owner = THIS_MODULE;
ret = cdev_add(&chip->poeg_cdev, MKDEV(MAJOR(g_poeg_dev), chip->index), 1);
@@ -296,6 +375,10 @@ static int rzg2l_poeg_probe(struct platform_device *pdev)
goto free_cdev;
}
+ ret = kfifo_alloc(&chip->events, 64, GFP_KERNEL);
+ if (ret)
+ goto free_cdev;
+
chip->minor_n = chip->index;
return ret;
@@ -311,6 +394,7 @@ static void rzg2l_poeg_remove(struct platform_device *pdev)
{
struct rzg2l_poeg_chip *chip = platform_get_drvdata(pdev);
+ kfifo_free(&chip->events);
device_destroy(poeg_class, MKDEV(MAJOR(g_poeg_dev), chip->minor_n));
cdev_del(&chip->poeg_cdev);
pm_runtime_put(&pdev->dev);
diff --git a/include/linux/pinctrl/rzg2l-poeg.h b/include/linux/pinctrl/rzg2l-poeg.h
index a5392f956700..311405b0137e 100644
--- a/include/linux/pinctrl/rzg2l-poeg.h
+++ b/include/linux/pinctrl/rzg2l-poeg.h
@@ -6,6 +6,15 @@
#define RZG2L_POEG_OUTPUT_DISABLE_USR_DISABLE_CMD 0
#define RZG2L_POEG_OUTPUT_DISABLE_USR_ENABLE_CMD 1
+#define RZG2L_POEG_GPT_CFG_IRQ_CMD 2
+#define RZG2L_POEG_GPT_FAULT_CLR_CMD 3
+
+#define RZG2L_GPT_OABHF 1
+
+struct poeg_event {
+ __u32 gpt_disable_irq_status;
+ __u8 channel;
+};
struct poeg_cmd {
__u32 val;
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread* [DO NOT APPLY PATCH v8 13/15] pinctrl: renesas: rzg2l-poeg: output-disable request from GPT when both outputs are low
2025-11-21 16:08 [PATCH v8 00/15] Add RZ/G2L POEG support Biju
` (11 preceding siblings ...)
2025-11-21 16:08 ` [DO NOT APPLY PATCH v8 12/15] pinctrl: renesas: rzg2l-poeg: Add support for GPT Output-Disable Request Biju
@ 2025-11-21 16:08 ` Biju
2025-11-21 16:08 ` [DO NOT APPLY PATCH v8 14/15] pinctrl: renesas: rzg2l-poeg: output-disable request from GPT on dead time error Biju
` (2 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Biju @ 2025-11-21 16:08 UTC (permalink / raw)
To: Uwe Kleine-König, Geert Uytterhoeven, Linus Walleij
Cc: Biju Das, linux-kernel, linux-pwm, Prabhakar Mahadev Lad,
Biju Das, linux-renesas-soc, linux-gpio
From: Biju Das <biju.das.jz@bp.renesas.com>
This patch adds support for output-disable requests from GPT, when both
outputs are low.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
drivers/pinctrl/renesas/poeg/rzg2l-poeg.c | 10 ++++++++++
include/linux/pinctrl/rzg2l-poeg.h | 1 +
2 files changed, 11 insertions(+)
diff --git a/drivers/pinctrl/renesas/poeg/rzg2l-poeg.c b/drivers/pinctrl/renesas/poeg/rzg2l-poeg.c
index 3dd8bc3465b1..f66f69c5b1f7 100644
--- a/drivers/pinctrl/renesas/poeg/rzg2l-poeg.c
+++ b/drivers/pinctrl/renesas/poeg/rzg2l-poeg.c
@@ -89,6 +89,9 @@ static void rzg2l_poeg_config_irq(struct rzg2l_poeg_chip *chip)
{
if (test_bit(RZG2L_GPT_OABHF, chip->gpt_irq))
rzg2l_gpt_poeg_disable_req_both_high(chip->gpt_dev, chip->index, true);
+
+ if (test_bit(RZG2L_GPT_OABLF, chip->gpt_irq))
+ rzg2l_gpt_poeg_disable_req_both_low(chip->gpt_dev, chip->index, true);
}
static irqreturn_t rzg2l_poeg_irq(int irq, void *ptr)
@@ -347,9 +350,16 @@ static int rzg2l_poeg_probe(struct platform_device *pdev)
case POEG_GPT_BOTH_HIGH:
assign_bit(RZG2L_GPT_OABHF, chip->gpt_irq, true);
break;
+ case POEG_GPT_BOTH_LOW:
+ assign_bit(RZG2L_GPT_OABLF, chip->gpt_irq, true);
+ break;
case POEG_EXT_PIN_CTRL:
rzg2l_poeg_write(chip, POEGG_PIDE);
break;
+ case POEG_GPT_BOTH_HIGH_LOW:
+ assign_bit(RZG2L_GPT_OABHF, chip->gpt_irq, true);
+ assign_bit(RZG2L_GPT_OABLF, chip->gpt_irq, true);
+ break;
default:
ret = -EINVAL;
goto err_pm;
diff --git a/include/linux/pinctrl/rzg2l-poeg.h b/include/linux/pinctrl/rzg2l-poeg.h
index 311405b0137e..ed3e08f10834 100644
--- a/include/linux/pinctrl/rzg2l-poeg.h
+++ b/include/linux/pinctrl/rzg2l-poeg.h
@@ -10,6 +10,7 @@
#define RZG2L_POEG_GPT_FAULT_CLR_CMD 3
#define RZG2L_GPT_OABHF 1
+#define RZG2L_GPT_OABLF 2
struct poeg_event {
__u32 gpt_disable_irq_status;
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread* [DO NOT APPLY PATCH v8 14/15] pinctrl: renesas: rzg2l-poeg: output-disable request from GPT on dead time error
2025-11-21 16:08 [PATCH v8 00/15] Add RZ/G2L POEG support Biju
` (12 preceding siblings ...)
2025-11-21 16:08 ` [DO NOT APPLY PATCH v8 13/15] pinctrl: renesas: rzg2l-poeg: output-disable request from GPT when both outputs are low Biju
@ 2025-11-21 16:08 ` Biju
2025-11-23 6:33 ` kernel test robot
2025-11-21 16:08 ` [DO NOT APPLY PATCH v8 15/15] tools: poeg: Add support for handling GPT output request disable Biju
2026-04-17 15:35 ` [PATCH v8 00/15] Add RZ/G2L POEG support Uwe Kleine-König
15 siblings, 1 reply; 20+ messages in thread
From: Biju @ 2025-11-21 16:08 UTC (permalink / raw)
To: Uwe Kleine-König, Geert Uytterhoeven, Linus Walleij
Cc: Biju Das, linux-kernel, linux-pwm, Prabhakar Mahadev Lad,
Biju Das, linux-renesas-soc, linux-gpio
From: Biju Das <biju.das.jz@bp.renesas.com>
Add support for output disable request from gpt, when dead time
error occurred.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
drivers/pinctrl/renesas/poeg/rzg2l-poeg.c | 19 +++++++++++++++++++
include/linux/pinctrl/rzg2l-poeg.h | 1 +
2 files changed, 20 insertions(+)
diff --git a/drivers/pinctrl/renesas/poeg/rzg2l-poeg.c b/drivers/pinctrl/renesas/poeg/rzg2l-poeg.c
index f66f69c5b1f7..d59e18832adf 100644
--- a/drivers/pinctrl/renesas/poeg/rzg2l-poeg.c
+++ b/drivers/pinctrl/renesas/poeg/rzg2l-poeg.c
@@ -92,6 +92,9 @@ static void rzg2l_poeg_config_irq(struct rzg2l_poeg_chip *chip)
if (test_bit(RZG2L_GPT_OABLF, chip->gpt_irq))
rzg2l_gpt_poeg_disable_req_both_low(chip->gpt_dev, chip->index, true);
+
+ if (test_bit(RZG2L_GPT_DTEF, chip->gpt_irq))
+ rzg2l_gpt_poeg_disable_req_deadtime_error(chip->gpt_dev, chip->index, true);
}
static irqreturn_t rzg2l_poeg_irq(int irq, void *ptr)
@@ -353,6 +356,9 @@ static int rzg2l_poeg_probe(struct platform_device *pdev)
case POEG_GPT_BOTH_LOW:
assign_bit(RZG2L_GPT_OABLF, chip->gpt_irq, true);
break;
+ case POEG_GPT_DEAD_TIME:
+ assign_bit(RZG2L_GPT_DTEF, chip->gpt_irq, true);
+ break;
case POEG_EXT_PIN_CTRL:
rzg2l_poeg_write(chip, POEGG_PIDE);
break;
@@ -360,6 +366,19 @@ static int rzg2l_poeg_probe(struct platform_device *pdev)
assign_bit(RZG2L_GPT_OABHF, chip->gpt_irq, true);
assign_bit(RZG2L_GPT_OABLF, chip->gpt_irq, true);
break;
+ case POEG_GPT_BOTH_HIGH_DEAD_TIME:
+ assign_bit(RZG2L_GPT_OABHF, chip->gpt_irq, true);
+ assign_bit(RZG2L_GPT_DTEF, chip->gpt_irq, true);
+ break;
+ case POEG_GPT_BOTH_LOW_DEAD_TIME:
+ assign_bit(RZG2L_GPT_OABLF, chip->gpt_irq, true);
+ assign_bit(RZG2L_GPT_DTEF, chip->gpt_irq, true);
+ break;
+ case POEG_GPT_ALL:
+ assign_bit(RZG2L_GPT_OABHF, chip->gpt_irq, true);
+ assign_bit(RZG2L_GPT_OABLF, chip->gpt_irq, true);
+ assign_bit(RZG2L_GPT_DTEF, chip->gpt_irq, true);
+ break;
default:
ret = -EINVAL;
goto err_pm;
diff --git a/include/linux/pinctrl/rzg2l-poeg.h b/include/linux/pinctrl/rzg2l-poeg.h
index ed3e08f10834..5edf719c155d 100644
--- a/include/linux/pinctrl/rzg2l-poeg.h
+++ b/include/linux/pinctrl/rzg2l-poeg.h
@@ -9,6 +9,7 @@
#define RZG2L_POEG_GPT_CFG_IRQ_CMD 2
#define RZG2L_POEG_GPT_FAULT_CLR_CMD 3
+#define RZG2L_GPT_DTEF 0
#define RZG2L_GPT_OABHF 1
#define RZG2L_GPT_OABLF 2
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [DO NOT APPLY PATCH v8 14/15] pinctrl: renesas: rzg2l-poeg: output-disable request from GPT on dead time error
2025-11-21 16:08 ` [DO NOT APPLY PATCH v8 14/15] pinctrl: renesas: rzg2l-poeg: output-disable request from GPT on dead time error Biju
@ 2025-11-23 6:33 ` kernel test robot
2025-11-23 9:17 ` Biju Das
0 siblings, 1 reply; 20+ messages in thread
From: kernel test robot @ 2025-11-23 6:33 UTC (permalink / raw)
To: Biju, Uwe Kleine-König, Geert Uytterhoeven, Linus Walleij
Cc: llvm, oe-kbuild-all, Biju Das, linux-kernel, linux-pwm,
Prabhakar Mahadev Lad, linux-renesas-soc, linux-gpio
Hi Biju,
kernel test robot noticed the following build errors:
[auto build test ERROR on geert-renesas-drivers/renesas-pinctrl]
[also build test ERROR on linusw-pinctrl/devel linusw-pinctrl/for-next geert-renesas-devel/next linus/master v6.18-rc6 next-20251121]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Biju/dt-bindings-pwm-rzg2l-gpt-Document-renesas-poegs-property/20251122-001415
base: https://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers.git renesas-pinctrl
patch link: https://lore.kernel.org/r/20251121160842.371922-15-biju.das.jz%40bp.renesas.com
patch subject: [DO NOT APPLY PATCH v8 14/15] pinctrl: renesas: rzg2l-poeg: output-disable request from GPT on dead time error
config: loongarch-randconfig-002-20251123 (https://download.01.org/0day-ci/archive/20251123/202511231456.D6amN8I5-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251123/202511231456.D6amN8I5-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202511231456.D6amN8I5-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/pinctrl/renesas/poeg/rzg2l-poeg.c:97:3: error: call to undeclared function 'rzg2l_gpt_poeg_disable_req_deadtime_error'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
97 | rzg2l_gpt_poeg_disable_req_deadtime_error(chip->gpt_dev, chip->index, true);
| ^
drivers/pinctrl/renesas/poeg/rzg2l-poeg.c:97:3: note: did you mean 'rzg2l_gpt_poeg_disable_req_deadtime_err'?
include/linux/pwm/rzg2l-gpt.h:38:19: note: 'rzg2l_gpt_poeg_disable_req_deadtime_err' declared here
38 | static inline int rzg2l_gpt_poeg_disable_req_deadtime_err(void *gpt_device, u8 grp, bool on)
| ^
1 error generated.
vim +/rzg2l_gpt_poeg_disable_req_deadtime_error +97 drivers/pinctrl/renesas/poeg/rzg2l-poeg.c
87
88 static void rzg2l_poeg_config_irq(struct rzg2l_poeg_chip *chip)
89 {
90 if (test_bit(RZG2L_GPT_OABHF, chip->gpt_irq))
91 rzg2l_gpt_poeg_disable_req_both_high(chip->gpt_dev, chip->index, true);
92
93 if (test_bit(RZG2L_GPT_OABLF, chip->gpt_irq))
94 rzg2l_gpt_poeg_disable_req_both_low(chip->gpt_dev, chip->index, true);
95
96 if (test_bit(RZG2L_GPT_DTEF, chip->gpt_irq))
> 97 rzg2l_gpt_poeg_disable_req_deadtime_error(chip->gpt_dev, chip->index, true);
98 }
99
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 20+ messages in thread* RE: [DO NOT APPLY PATCH v8 14/15] pinctrl: renesas: rzg2l-poeg: output-disable request from GPT on dead time error
2025-11-23 6:33 ` kernel test robot
@ 2025-11-23 9:17 ` Biju Das
0 siblings, 0 replies; 20+ messages in thread
From: Biju Das @ 2025-11-23 9:17 UTC (permalink / raw)
To: kernel test robot, biju.das.au, Uwe Kleine-König,
Geert Uytterhoeven, Linus Walleij
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org,
Prabhakar Mahadev Lad, linux-renesas-soc@vger.kernel.org,
linux-gpio@vger.kernel.org
Hi All,
> -----Original Message-----
> From: kernel test robot <lkp@intel.com>
> Sent: 23 November 2025 06:34
> Subject: Re: [DO NOT APPLY PATCH v8 14/15] pinctrl: renesas: rzg2l-poeg: output-disable request from
> GPT on dead time error
>
> Hi Biju,
>
> kernel test robot noticed the following build errors:
>
> [auto build test ERROR on geert-renesas-drivers/renesas-pinctrl]
> [also build test ERROR on linusw-pinctrl/devel linusw-pinctrl/for-next geert-renesas-devel/next
> linus/master v6.18-rc6 next-20251121] [If your patch is applied to the wrong git tree, kindly drop us
> a note.
> And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-
> format-patch#_base_tree_information]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Biju/dt-bindings-pwm-rzg2l-gpt-Document-
> renesas-poegs-property/20251122-001415
> base: https://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers.git renesas-pinctrl
> patch link: https://lore.kernel.org/r/20251121160842.371922-15-biju.das.jz%40bp.renesas.com
> patch subject: [DO NOT APPLY PATCH v8 14/15] pinctrl: renesas: rzg2l-poeg: output-disable request from
> GPT on dead time error
> config: loongarch-randconfig-002-20251123 (https://download.01.org/0day-
> ci/archive/20251123/202511231456.D6amN8I5-lkp@intel.com/config)
> compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project
> 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
> reproduce (this is a W=1 build): (https://download.01.org/0day-
> ci/archive/20251123/202511231456.D6amN8I5-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of the same
> patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes:
> | https://lore.kernel.org/oe-kbuild-all/202511231456.D6amN8I5-lkp@intel.
> | com/
>
> All errors (new ones prefixed by >>):
>
> >> drivers/pinctrl/renesas/poeg/rzg2l-poeg.c:97:3: error: call to
> >> undeclared function 'rzg2l_gpt_poeg_disable_req_deadtime_error'; ISO
> >> C99 and later do not support implicit function declarations
> >> [-Wimplicit-function-declaration]
> 97 | rzg2l_gpt_poeg_disable_req_deadtime_error(chip->gpt_dev, chip->index,
> true);
> | ^
> drivers/pinctrl/renesas/poeg/rzg2l-poeg.c:97:3: note: did you mean
> 'rzg2l_gpt_poeg_disable_req_deadtime_err'?
> include/linux/pwm/rzg2l-gpt.h:38:19: note: 'rzg2l_gpt_poeg_disable_req_deadtime_err' declared here
> 38 | static inline int rzg2l_gpt_poeg_disable_req_deadtime_err(void *gpt_device, u8 grp, bool
Will fix the inline function as rzg2l_gpt_poeg_disable_req_deadtime_error.
Cheers,
Biju
> on)
> | ^
> 1 error generated.
>
>
> vim +/rzg2l_gpt_poeg_disable_req_deadtime_error +97 drivers/pinctrl/renesas/poeg/rzg2l-poeg.c
>
> 87
> 88 static void rzg2l_poeg_config_irq(struct rzg2l_poeg_chip *chip)
> 89 {
> 90 if (test_bit(RZG2L_GPT_OABHF, chip->gpt_irq))
> 91 rzg2l_gpt_poeg_disable_req_both_high(chip->gpt_dev, chip->index, true);
> 92
> 93 if (test_bit(RZG2L_GPT_OABLF, chip->gpt_irq))
> 94 rzg2l_gpt_poeg_disable_req_both_low(chip->gpt_dev, chip->index, true);
> 95
> 96 if (test_bit(RZG2L_GPT_DTEF, chip->gpt_irq))
> > 97 rzg2l_gpt_poeg_disable_req_deadtime_error(chip->gpt_dev, chip->index, true);
> 98 }
> 99
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* [DO NOT APPLY PATCH v8 15/15] tools: poeg: Add support for handling GPT output request disable
2025-11-21 16:08 [PATCH v8 00/15] Add RZ/G2L POEG support Biju
` (13 preceding siblings ...)
2025-11-21 16:08 ` [DO NOT APPLY PATCH v8 14/15] pinctrl: renesas: rzg2l-poeg: output-disable request from GPT on dead time error Biju
@ 2025-11-21 16:08 ` Biju
2026-04-17 15:35 ` [PATCH v8 00/15] Add RZ/G2L POEG support Uwe Kleine-König
15 siblings, 0 replies; 20+ messages in thread
From: Biju @ 2025-11-21 16:08 UTC (permalink / raw)
To: Uwe Kleine-König, Geert Uytterhoeven, Linus Walleij
Cc: Biju Das, linux-kernel, linux-pwm, Prabhakar Mahadev Lad,
Biju Das, linux-renesas-soc, linux-gpio
From: Biju Das <biju.das.jz@bp.renesas.com>
Add support for handling GPT output request disable. When GPT
detects output disable condition, it request POEG and POEG
triggers an interrupt after disabling the output. the clearing
of interrupt happens in GPT. Add support for handling this in
userspace, when POEG triggers interrupt, it sends an event to
user space and user space send clear command to clear the gpt
request for output disable.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
tools/poeg/poeg_app.c | 57 +++++++++++++++++++++++++++++++++++--------
1 file changed, 47 insertions(+), 10 deletions(-)
diff --git a/tools/poeg/poeg_app.c b/tools/poeg/poeg_app.c
index 4ff8e5c007dc..71f130d5aad2 100644
--- a/tools/poeg/poeg_app.c
+++ b/tools/poeg/poeg_app.c
@@ -20,9 +20,11 @@
int main(int argc, char *argv[])
{
+ struct poeg_event event_data;
struct poeg_cmd cmd;
unsigned int val;
long cmd_val;
+ int ret, fd;
char *p;
int i;
@@ -36,17 +38,52 @@ int main(int argc, char *argv[])
else
printf("[POEG]open\n");
- cmd.val = cmd_val;
- cmd.channel = 4;
- if (cmd.val == RZG2L_POEG_OUTPUT_DISABLE_USR_ENABLE_CMD)
- printf("[POEG] user control pin output disable enabled\n");
- else
- printf("[POEG] user control pin output disable disabled\n");
+ if (cmd_val == RZG2L_POEG_OUTPUT_DISABLE_USR_ENABLE_CMD ||
+ cmd_val == RZG2L_POEG_OUTPUT_DISABLE_USR_DISABLE_CMD) {
+ if (cmd_val == RZG2L_POEG_OUTPUT_DISABLE_USR_ENABLE_CMD)
+ printf("[POEG] user control pin output disable enabled\n");
+ else
+ printf("[POEG] user control pin output disable disabled\n");
+
+ cmd.val = cmd_val;
+ cmd.channel = 4;
+ ret = write(fd, &cmd, sizeof(cmd));
+ if (ret == -1) {
+ perror("Failed to write cmd data");
+ return 1;
+ }
+ } else {
+ printf("[POEG] GPT control configure IRQ\n");
+ cmd.val = RZG2L_POEG_GPT_CFG_IRQ_CMD;
+ cmd.channel = 4;
+ ret = write(fd, &cmd, sizeof(cmd));
+ if (ret == -1) {
+ perror("Failed to write cmd data");
+ return 1;
+ }
+
+ for (;;) {
+ ret = read(fd, &event_data, sizeof(event_data));
+ if (ret == -1) {
+ perror("Failed to read event data");
+ return 1;
+ }
- ret = write(fd, &cmd, sizeof(cmd));
- if (ret == -1) {
- perror("Failed to write cmd data");
- return 1;
+ val = event_data.gpt_disable_irq_status;
+ if (val) {
+ /* emulate fault clearing condition by adding delay */
+ sleep(2);
+ for (i = 0; i < 8; i++) {
+ if (val & 7) {
+ printf("gpt ch:%u, irq=%x\n", i, val & 7);
+ cmd.val = RZG2L_POEG_GPT_FAULT_CLR_CMD;
+ cmd.channel = 4;
+ ret = write(fd, &cmd, sizeof(cmd));
+ }
+ val >>= 3;
+ }
+ }
+ }
}
if (close(fd) != 0)
--
2.43.0
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [PATCH v8 00/15] Add RZ/G2L POEG support
2025-11-21 16:08 [PATCH v8 00/15] Add RZ/G2L POEG support Biju
` (14 preceding siblings ...)
2025-11-21 16:08 ` [DO NOT APPLY PATCH v8 15/15] tools: poeg: Add support for handling GPT output request disable Biju
@ 2026-04-17 15:35 ` Uwe Kleine-König
2026-04-17 16:07 ` Biju Das
15 siblings, 1 reply; 20+ messages in thread
From: Uwe Kleine-König @ 2026-04-17 15:35 UTC (permalink / raw)
To: Biju
Cc: Geert Uytterhoeven, Linus Walleij, Philipp Zabel, Magnus Damm,
Biju Das, linux-kernel, linux-pwm, linux-renesas-soc, linux-gpio,
Prabhakar Mahadev Lad
[-- Attachment #1: Type: text/plain, Size: 357 bytes --]
Hello Biju,
there are currently two series by you open touching the same driver
(this series and "[PATCH v4 0/9] Add RZ/G3E GPT support"). Would you
please make it easier for me and create a single series containing
everything that you still want to get in? (Or if one of the series
became irrelevant, that would also be actable for me.)
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread* RE: [PATCH v8 00/15] Add RZ/G2L POEG support
2026-04-17 15:35 ` [PATCH v8 00/15] Add RZ/G2L POEG support Uwe Kleine-König
@ 2026-04-17 16:07 ` Biju Das
0 siblings, 0 replies; 20+ messages in thread
From: Biju Das @ 2026-04-17 16:07 UTC (permalink / raw)
To: Uwe Kleine-König, biju.das.au
Cc: Geert Uytterhoeven, Linus Walleij, Philipp Zabel, magnus.damm,
linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org,
linux-renesas-soc@vger.kernel.org, linux-gpio@vger.kernel.org,
Prabhakar Mahadev Lad
Hello Uwe,
Thanks for the feedback.
> -----Original Message-----
> From: Uwe Kleine-König <ukleinek@kernel.org>
> Sent: 17 April 2026 16:36
> Subject: Re: [PATCH v8 00/15] Add RZ/G2L POEG support
>
> Hello Biju,
>
> there are currently two series by you open touching the same driver (this series and "[PATCH v4 0/9]
> Add RZ/G3E GPT support"). Would you please make it easier for me and create a single series containing
> everything that you still want to get in? (Or if one of the series became irrelevant, that would also
> be actable for me.)
OK, will create a single series for PWM specific patches to make it easier.
Cheers,
Biju
^ permalink raw reply [flat|nested] 20+ messages in thread