Linux RTC
 help / color / mirror / Atom feed
* [PATCH 0/3] Samsung mfd/rtc driver alarm IRQ simplification
@ 2025-11-14 11:47 André Draszik
  2025-11-14 11:47 ` [PATCH 1/3] mfd: sec: add rtc alarm IRQ as platform device resource André Draszik
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: André Draszik @ 2025-11-14 11:47 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Lee Jones, Alexandre Belloni
  Cc: Peter Griffin, Tudor Ambarus, Will McVicker, Juan Yescas,
	Douglas Anderson, kernel-team, Kaustabh Chakraborty, linux-kernel,
	linux-samsung-soc, linux-rtc, André Draszik

Hi,

With the attached patches the Samsung s5m RTC driver is simplified a
little bit with regards to alarm IRQ acquisition.

The end result is that instead of having a list of IRQ numbers for each
variant (and a BUILD_BUG_ON() to ensure consistency), the RTC driver
queries the 'alarm' platform resource from the parent (mfd cell).

Additionally, we can drop a now-useless field from runtime data,
reducing memory consumption slightly.

The attached patches must be applied in-order. I would expect them all
to go via the MFD tree. Alternatively, they could be applied one after
another during multiple kernel release cycles, but that seems a
needless complication.

Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
André Draszik (3):
      mfd: sec: add rtc alarm IRQ as platform device resource
      rtc: s5m: query platform device IRQ resource for alarm IRQ
      mfd: sec: drop now unused struct sec_pmic_dev::irq_data

 drivers/mfd/sec-common.c         | 41 ++++++++++++++++++++++++++++++----------
 drivers/mfd/sec-core.h           |  2 +-
 drivers/mfd/sec-irq.c            | 10 ++--------
 drivers/rtc/rtc-s5m.c            | 21 ++++++++------------
 include/linux/mfd/samsung/core.h |  1 -
 5 files changed, 42 insertions(+), 33 deletions(-)
---
base-commit: b179ce312bafcb8c68dc718e015aee79b7939ff0
change-id: 20251114-s5m-alarm-3de705ea53ce

Best regards,
-- 
André Draszik <andre.draszik@linaro.org>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/3] mfd: sec: add rtc alarm IRQ as platform device resource
  2025-11-14 11:47 [PATCH 0/3] Samsung mfd/rtc driver alarm IRQ simplification André Draszik
@ 2025-11-14 11:47 ` André Draszik
  2025-11-14 11:47 ` [PATCH 2/3] rtc: s5m: query platform device IRQ resource for alarm IRQ André Draszik
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: André Draszik @ 2025-11-14 11:47 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Lee Jones, Alexandre Belloni
  Cc: Peter Griffin, Tudor Ambarus, Will McVicker, Juan Yescas,
	Douglas Anderson, kernel-team, Kaustabh Chakraborty, linux-kernel,
	linux-samsung-soc, linux-rtc, André Draszik

By adding the RTC alarm IRQ to the MFD cell as a resource, the child
driver (rtc) can simply query that IRQ, instead of having a lookup
table itself.

This change therefore allows the child driver to be simplified with
regards to determining the alarm IRQ.

Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 drivers/mfd/sec-common.c | 38 +++++++++++++++++++++++++++++---------
 1 file changed, 29 insertions(+), 9 deletions(-)

diff --git a/drivers/mfd/sec-common.c b/drivers/mfd/sec-common.c
index 42d55e70e34c8d7cd68cddaecc88017e259365b4..77370db52a7ba81234136b29f85892f4b197f429 100644
--- a/drivers/mfd/sec-common.c
+++ b/drivers/mfd/sec-common.c
@@ -23,9 +23,13 @@
 #include <linux/regmap.h>
 #include "sec-core.h"
 
+static const struct resource s5m8767_rtc_resources[] = {
+	DEFINE_RES_IRQ_NAMED(S5M8767_IRQ_RTCA1, "alarm"),
+};
+
 static const struct mfd_cell s5m8767_devs[] = {
 	MFD_CELL_NAME("s5m8767-pmic"),
-	MFD_CELL_NAME("s5m-rtc"),
+	MFD_CELL_RES("s5m-rtc", s5m8767_rtc_resources),
 	MFD_CELL_OF("s5m8767-clk", NULL, NULL, 0, 0, "samsung,s5m8767-clk"),
 };
 
@@ -33,50 +37,66 @@ static const struct mfd_cell s2dos05_devs[] = {
 	MFD_CELL_NAME("s2dos05-regulator"),
 };
 
+static const struct resource s2mpg10_rtc_resources[] = {
+	DEFINE_RES_IRQ_NAMED(S2MPG10_IRQ_RTCA0, "alarm"),
+};
+
 static const struct mfd_cell s2mpg10_devs[] = {
 	MFD_CELL_NAME("s2mpg10-meter"),
 	MFD_CELL_NAME("s2mpg10-regulator"),
-	MFD_CELL_NAME("s2mpg10-rtc"),
+	MFD_CELL_RES("s2mpg10-rtc", s2mpg10_rtc_resources),
 	MFD_CELL_OF("s2mpg10-clk", NULL, NULL, 0, 0, "samsung,s2mpg10-clk"),
 	MFD_CELL_OF("s2mpg10-gpio", NULL, NULL, 0, 0, "samsung,s2mpg10-gpio"),
 };
 
+static const struct resource s2mps11_rtc_resources[] = {
+	DEFINE_RES_IRQ_NAMED(S2MPS11_IRQ_RTCA0, "alarm"),
+};
+
 static const struct mfd_cell s2mps11_devs[] = {
 	MFD_CELL_NAME("s2mps11-regulator"),
-	MFD_CELL_NAME("s2mps14-rtc"),
+	MFD_CELL_RES("s2mps14-rtc", s2mps11_rtc_resources),
 	MFD_CELL_OF("s2mps11-clk", NULL, NULL, 0, 0, "samsung,s2mps11-clk"),
 };
 
+static const struct resource s2mps14_rtc_resources[] = {
+	DEFINE_RES_IRQ_NAMED(S2MPS14_IRQ_RTCA0, "alarm"),
+};
+
 static const struct mfd_cell s2mps13_devs[] = {
 	MFD_CELL_NAME("s2mps13-regulator"),
-	MFD_CELL_NAME("s2mps13-rtc"),
+	MFD_CELL_RES("s2mps13-rtc", s2mps14_rtc_resources),
 	MFD_CELL_OF("s2mps13-clk", NULL, NULL, 0, 0, "samsung,s2mps13-clk"),
 };
 
 static const struct mfd_cell s2mps14_devs[] = {
 	MFD_CELL_NAME("s2mps14-regulator"),
-	MFD_CELL_NAME("s2mps14-rtc"),
+	MFD_CELL_RES("s2mps14-rtc", s2mps14_rtc_resources),
 	MFD_CELL_OF("s2mps14-clk", NULL, NULL, 0, 0, "samsung,s2mps14-clk"),
 };
 
 static const struct mfd_cell s2mps15_devs[] = {
 	MFD_CELL_NAME("s2mps15-regulator"),
-	MFD_CELL_NAME("s2mps15-rtc"),
+	MFD_CELL_RES("s2mps15-rtc", s2mps14_rtc_resources),
 	MFD_CELL_OF("s2mps13-clk", NULL, NULL, 0, 0, "samsung,s2mps13-clk"),
 };
 
 static const struct mfd_cell s2mpa01_devs[] = {
 	MFD_CELL_NAME("s2mpa01-pmic"),
-	MFD_CELL_NAME("s2mps14-rtc"),
+	MFD_CELL_RES("s2mps14-rtc", s2mps14_rtc_resources),
 };
 
 static const struct mfd_cell s2mpu02_devs[] = {
 	MFD_CELL_NAME("s2mpu02-regulator"),
 };
 
+static const struct resource s2mpu05_rtc_resources[] = {
+	DEFINE_RES_IRQ_NAMED(S2MPU05_IRQ_RTCA0, "alarm"),
+};
+
 static const struct mfd_cell s2mpu05_devs[] = {
 	MFD_CELL_NAME("s2mpu05-regulator"),
-	MFD_CELL_NAME("s2mps15-rtc"),
+	MFD_CELL_RES("s2mps15-rtc", s2mpu05_rtc_resources),
 };
 
 static void sec_pmic_dump_rev(struct sec_pmic_dev *sec_pmic)
@@ -220,7 +240,7 @@ int sec_pmic_probe(struct device *dev, int device_type, unsigned int irq,
 				     sec_pmic->device_type);
 	}
 	ret = devm_mfd_add_devices(sec_pmic->dev, -1, sec_devs, num_sec_devs,
-				   NULL, 0, NULL);
+				   NULL, 0, regmap_irq_get_domain(sec_pmic->irq_data));
 	if (ret)
 		return ret;
 

-- 
2.52.0.rc1.455.g30608eb744-goog


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/3] rtc: s5m: query platform device IRQ resource for alarm IRQ
  2025-11-14 11:47 [PATCH 0/3] Samsung mfd/rtc driver alarm IRQ simplification André Draszik
  2025-11-14 11:47 ` [PATCH 1/3] mfd: sec: add rtc alarm IRQ as platform device resource André Draszik
@ 2025-11-14 11:47 ` André Draszik
  2025-11-14 15:58   ` Alexandre Belloni
  2025-11-14 11:47 ` [PATCH 3/3] mfd: sec: drop now unused struct sec_pmic_dev::irq_data André Draszik
  2025-11-20 10:31 ` [PATCH 0/3] Samsung mfd/rtc driver alarm IRQ simplification Lee Jones
  3 siblings, 1 reply; 9+ messages in thread
From: André Draszik @ 2025-11-14 11:47 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Lee Jones, Alexandre Belloni
  Cc: Peter Griffin, Tudor Ambarus, Will McVicker, Juan Yescas,
	Douglas Anderson, kernel-team, Kaustabh Chakraborty, linux-kernel,
	linux-samsung-soc, linux-rtc, André Draszik

The core driver now exposes the alarm IRQ as a resource, so we can drop
the lookup from here to simplify the code and make adding support for
additional variants easier in this driver.

Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 drivers/rtc/rtc-s5m.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/rtc/rtc-s5m.c b/drivers/rtc/rtc-s5m.c
index a7220b4d0e8dd35786b060e2a4106e2a39fe743f..c6ed5a4ca8a0e4554b1c88c879b01fc384735007 100644
--- a/drivers/rtc/rtc-s5m.c
+++ b/drivers/rtc/rtc-s5m.c
@@ -15,7 +15,6 @@
 #include <linux/rtc.h>
 #include <linux/platform_device.h>
 #include <linux/mfd/samsung/core.h>
-#include <linux/mfd/samsung/irq.h>
 #include <linux/mfd/samsung/rtc.h>
 #include <linux/mfd/samsung/s2mps14.h>
 
@@ -683,22 +682,18 @@ static int s5m_rtc_probe(struct platform_device *pdev)
 		case S2MPS15X:
 			regmap_cfg = &s2mps14_rtc_regmap_config;
 			info->regs = &s2mps15_rtc_regs;
-			alarm_irq = S2MPS14_IRQ_RTCA0;
 			break;
 		case S2MPS14X:
 			regmap_cfg = &s2mps14_rtc_regmap_config;
 			info->regs = &s2mps14_rtc_regs;
-			alarm_irq = S2MPS14_IRQ_RTCA0;
 			break;
 		case S2MPS13X:
 			regmap_cfg = &s2mps14_rtc_regmap_config;
 			info->regs = &s2mps13_rtc_regs;
-			alarm_irq = S2MPS14_IRQ_RTCA0;
 			break;
 		case S5M8767X:
 			regmap_cfg = &s5m_rtc_regmap_config;
 			info->regs = &s5m_rtc_regs;
-			alarm_irq = S5M8767_IRQ_RTCA1;
 			break;
 		default:
 			return dev_err_probe(&pdev->dev, -ENODEV,
@@ -719,7 +714,6 @@ static int s5m_rtc_probe(struct platform_device *pdev)
 					     "Failed to allocate regmap\n");
 	} else if (device_type == S2MPG10) {
 		info->regs = &s2mpg10_rtc_regs;
-		alarm_irq = S2MPG10_IRQ_RTCA0;
 	} else {
 		return dev_err_probe(&pdev->dev, -ENODEV,
 				     "Unsupported device type %d\n",
@@ -730,13 +724,14 @@ static int s5m_rtc_probe(struct platform_device *pdev)
 	info->s5m87xx = s5m87xx;
 	info->device_type = device_type;
 
-	if (s5m87xx->irq_data) {
-		info->irq = regmap_irq_get_virq(s5m87xx->irq_data, alarm_irq);
-		if (info->irq <= 0)
-			return dev_err_probe(&pdev->dev, -EINVAL,
-					     "Failed to get virtual IRQ %d\n",
-					     alarm_irq);
-	}
+	alarm_irq = platform_get_irq_byname_optional(pdev, "alarm");
+	if (alarm_irq > 0)
+		info->irq = alarm_irq;
+	else if (alarm_irq == -ENXIO)
+		info->irq = 0;
+	else
+		return dev_err_probe(&pdev->dev, alarm_irq ? : -EINVAL,
+				     "IRQ 'alarm' not found\n");
 
 	platform_set_drvdata(pdev, info);
 

-- 
2.52.0.rc1.455.g30608eb744-goog


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/3] mfd: sec: drop now unused struct sec_pmic_dev::irq_data
  2025-11-14 11:47 [PATCH 0/3] Samsung mfd/rtc driver alarm IRQ simplification André Draszik
  2025-11-14 11:47 ` [PATCH 1/3] mfd: sec: add rtc alarm IRQ as platform device resource André Draszik
  2025-11-14 11:47 ` [PATCH 2/3] rtc: s5m: query platform device IRQ resource for alarm IRQ André Draszik
@ 2025-11-14 11:47 ` André Draszik
  2025-11-20 10:35   ` Lee Jones
  2025-11-20 10:31 ` [PATCH 0/3] Samsung mfd/rtc driver alarm IRQ simplification Lee Jones
  3 siblings, 1 reply; 9+ messages in thread
From: André Draszik @ 2025-11-14 11:47 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Lee Jones, Alexandre Belloni
  Cc: Peter Griffin, Tudor Ambarus, Will McVicker, Juan Yescas,
	Douglas Anderson, kernel-team, Kaustabh Chakraborty, linux-kernel,
	linux-samsung-soc, linux-rtc, André Draszik

This was used only to allow the s5m RTC driver to deal with the alarm
IRQ. That driver now uses a different approach to acquire that IRQ, and
::irq_data doesn't need to be kept around anymore.

Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 drivers/mfd/sec-common.c         |  5 +++--
 drivers/mfd/sec-core.h           |  2 +-
 drivers/mfd/sec-irq.c            | 10 ++--------
 include/linux/mfd/samsung/core.h |  1 -
 4 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/mfd/sec-common.c b/drivers/mfd/sec-common.c
index 77370db52a7ba81234136b29f85892f4b197f429..794c4e5398e7dd1a816aff9a6559a6c19fec75a5 100644
--- a/drivers/mfd/sec-common.c
+++ b/drivers/mfd/sec-common.c
@@ -163,6 +163,7 @@ sec_pmic_parse_dt_pdata(struct device *dev)
 int sec_pmic_probe(struct device *dev, int device_type, unsigned int irq,
 		   struct regmap *regmap, struct i2c_client *client)
 {
+	struct regmap_irq_chip_data *irq_data;
 	struct sec_platform_data *pdata;
 	const struct mfd_cell *sec_devs;
 	struct sec_pmic_dev *sec_pmic;
@@ -187,7 +188,7 @@ int sec_pmic_probe(struct device *dev, int device_type, unsigned int irq,
 
 	sec_pmic->pdata = pdata;
 
-	ret = sec_irq_init(sec_pmic);
+	ret = sec_irq_init(sec_pmic, &irq_data);
 	if (ret)
 		return ret;
 
@@ -240,7 +241,7 @@ int sec_pmic_probe(struct device *dev, int device_type, unsigned int irq,
 				     sec_pmic->device_type);
 	}
 	ret = devm_mfd_add_devices(sec_pmic->dev, -1, sec_devs, num_sec_devs,
-				   NULL, 0, regmap_irq_get_domain(sec_pmic->irq_data));
+				   NULL, 0, regmap_irq_get_domain(irq_data));
 	if (ret)
 		return ret;
 
diff --git a/drivers/mfd/sec-core.h b/drivers/mfd/sec-core.h
index 92c7558ab8b0de44a52e028eeb7998e38358cb4c..c639180ea686f4308af3f872cb1d2209d201b2e7 100644
--- a/drivers/mfd/sec-core.h
+++ b/drivers/mfd/sec-core.h
@@ -18,6 +18,6 @@ int sec_pmic_probe(struct device *dev, int device_type, unsigned int irq,
 		   struct regmap *regmap, struct i2c_client *client);
 void sec_pmic_shutdown(struct device *dev);
 
-int sec_irq_init(struct sec_pmic_dev *sec_pmic);
+int sec_irq_init(struct sec_pmic_dev *sec_pmic, struct regmap_irq_chip_data **irq_data);
 
 #endif /* __SEC_CORE_INT_H */
diff --git a/drivers/mfd/sec-irq.c b/drivers/mfd/sec-irq.c
index c5c80b1ba104e6c5a55b442d2f10a8554201a961..05d4cc350a351d994e00ba08f5ce966d0d5c6a0b 100644
--- a/drivers/mfd/sec-irq.c
+++ b/drivers/mfd/sec-irq.c
@@ -253,7 +253,7 @@ static const struct regmap_irq_chip s5m8767_irq_chip = {
 	.ack_base = S5M8767_REG_INT1,
 };
 
-int sec_irq_init(struct sec_pmic_dev *sec_pmic)
+int sec_irq_init(struct sec_pmic_dev *sec_pmic, struct regmap_irq_chip_data **irq_data)
 {
 	const struct regmap_irq_chip *sec_irq_chip;
 	int ret;
@@ -302,17 +302,11 @@ int sec_irq_init(struct sec_pmic_dev *sec_pmic)
 
 	ret = devm_regmap_add_irq_chip(sec_pmic->dev, sec_pmic->regmap_pmic,
 				       sec_pmic->irq, IRQF_ONESHOT,
-				       0, sec_irq_chip, &sec_pmic->irq_data);
+				       0, sec_irq_chip, irq_data);
 	if (ret)
 		return dev_err_probe(sec_pmic->dev, ret,
 				     "Failed to add %s IRQ chip\n",
 				     sec_irq_chip->name);
 
-	/*
-	 * The rtc-s5m driver requests S2MPS14_IRQ_RTCA0 also for S2MPS11
-	 * so the interrupt number must be consistent.
-	 */
-	BUILD_BUG_ON(((enum s2mps14_irq)S2MPS11_IRQ_RTCA0) != S2MPS14_IRQ_RTCA0);
-
 	return 0;
 }
diff --git a/include/linux/mfd/samsung/core.h b/include/linux/mfd/samsung/core.h
index d785e101fe795a5d8f9cccf4ccc4232437e89416..c7c3c8cd8d5f99ef0cc3188e1c3b49031f4750f2 100644
--- a/include/linux/mfd/samsung/core.h
+++ b/include/linux/mfd/samsung/core.h
@@ -69,7 +69,6 @@ struct sec_pmic_dev {
 
 	int device_type;
 	int irq;
-	struct regmap_irq_chip_data *irq_data;
 };
 
 struct sec_platform_data {

-- 
2.52.0.rc1.455.g30608eb744-goog


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/3] rtc: s5m: query platform device IRQ resource for alarm IRQ
  2025-11-14 11:47 ` [PATCH 2/3] rtc: s5m: query platform device IRQ resource for alarm IRQ André Draszik
@ 2025-11-14 15:58   ` Alexandre Belloni
  0 siblings, 0 replies; 9+ messages in thread
From: Alexandre Belloni @ 2025-11-14 15:58 UTC (permalink / raw)
  To: André Draszik
  Cc: Krzysztof Kozlowski, Lee Jones, Peter Griffin, Tudor Ambarus,
	Will McVicker, Juan Yescas, Douglas Anderson, kernel-team,
	Kaustabh Chakraborty, linux-kernel, linux-samsung-soc, linux-rtc

On 14/11/2025 11:47:22+0000, André Draszik wrote:
> The core driver now exposes the alarm IRQ as a resource, so we can drop
> the lookup from here to simplify the code and make adding support for
> additional variants easier in this driver.
> 
> Signed-off-by: André Draszik <andre.draszik@linaro.org>

Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

> ---
>  drivers/rtc/rtc-s5m.c | 21 ++++++++-------------
>  1 file changed, 8 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-s5m.c b/drivers/rtc/rtc-s5m.c
> index a7220b4d0e8dd35786b060e2a4106e2a39fe743f..c6ed5a4ca8a0e4554b1c88c879b01fc384735007 100644
> --- a/drivers/rtc/rtc-s5m.c
> +++ b/drivers/rtc/rtc-s5m.c
> @@ -15,7 +15,6 @@
>  #include <linux/rtc.h>
>  #include <linux/platform_device.h>
>  #include <linux/mfd/samsung/core.h>
> -#include <linux/mfd/samsung/irq.h>
>  #include <linux/mfd/samsung/rtc.h>
>  #include <linux/mfd/samsung/s2mps14.h>
>  
> @@ -683,22 +682,18 @@ static int s5m_rtc_probe(struct platform_device *pdev)
>  		case S2MPS15X:
>  			regmap_cfg = &s2mps14_rtc_regmap_config;
>  			info->regs = &s2mps15_rtc_regs;
> -			alarm_irq = S2MPS14_IRQ_RTCA0;
>  			break;
>  		case S2MPS14X:
>  			regmap_cfg = &s2mps14_rtc_regmap_config;
>  			info->regs = &s2mps14_rtc_regs;
> -			alarm_irq = S2MPS14_IRQ_RTCA0;
>  			break;
>  		case S2MPS13X:
>  			regmap_cfg = &s2mps14_rtc_regmap_config;
>  			info->regs = &s2mps13_rtc_regs;
> -			alarm_irq = S2MPS14_IRQ_RTCA0;
>  			break;
>  		case S5M8767X:
>  			regmap_cfg = &s5m_rtc_regmap_config;
>  			info->regs = &s5m_rtc_regs;
> -			alarm_irq = S5M8767_IRQ_RTCA1;
>  			break;
>  		default:
>  			return dev_err_probe(&pdev->dev, -ENODEV,
> @@ -719,7 +714,6 @@ static int s5m_rtc_probe(struct platform_device *pdev)
>  					     "Failed to allocate regmap\n");
>  	} else if (device_type == S2MPG10) {
>  		info->regs = &s2mpg10_rtc_regs;
> -		alarm_irq = S2MPG10_IRQ_RTCA0;
>  	} else {
>  		return dev_err_probe(&pdev->dev, -ENODEV,
>  				     "Unsupported device type %d\n",
> @@ -730,13 +724,14 @@ static int s5m_rtc_probe(struct platform_device *pdev)
>  	info->s5m87xx = s5m87xx;
>  	info->device_type = device_type;
>  
> -	if (s5m87xx->irq_data) {
> -		info->irq = regmap_irq_get_virq(s5m87xx->irq_data, alarm_irq);
> -		if (info->irq <= 0)
> -			return dev_err_probe(&pdev->dev, -EINVAL,
> -					     "Failed to get virtual IRQ %d\n",
> -					     alarm_irq);
> -	}
> +	alarm_irq = platform_get_irq_byname_optional(pdev, "alarm");
> +	if (alarm_irq > 0)
> +		info->irq = alarm_irq;
> +	else if (alarm_irq == -ENXIO)
> +		info->irq = 0;
> +	else
> +		return dev_err_probe(&pdev->dev, alarm_irq ? : -EINVAL,
> +				     "IRQ 'alarm' not found\n");
>  
>  	platform_set_drvdata(pdev, info);
>  
> 
> -- 
> 2.52.0.rc1.455.g30608eb744-goog
> 

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/3] Samsung mfd/rtc driver alarm IRQ simplification
  2025-11-14 11:47 [PATCH 0/3] Samsung mfd/rtc driver alarm IRQ simplification André Draszik
                   ` (2 preceding siblings ...)
  2025-11-14 11:47 ` [PATCH 3/3] mfd: sec: drop now unused struct sec_pmic_dev::irq_data André Draszik
@ 2025-11-20 10:31 ` Lee Jones
  2025-11-20 10:32   ` André Draszik
  3 siblings, 1 reply; 9+ messages in thread
From: Lee Jones @ 2025-11-20 10:31 UTC (permalink / raw)
  To: André Draszik
  Cc: Krzysztof Kozlowski, Alexandre Belloni, Peter Griffin,
	Tudor Ambarus, Will McVicker, Juan Yescas, Douglas Anderson,
	kernel-team, Kaustabh Chakraborty, linux-kernel,
	linux-samsung-soc, linux-rtc

On Fri, 14 Nov 2025, André Draszik wrote:

> Hi,
> 
> With the attached patches the Samsung s5m RTC driver is simplified a
> little bit with regards to alarm IRQ acquisition.
> 
> The end result is that instead of having a list of IRQ numbers for each
> variant (and a BUILD_BUG_ON() to ensure consistency), the RTC driver
> queries the 'alarm' platform resource from the parent (mfd cell).
> 
> Additionally, we can drop a now-useless field from runtime data,
> reducing memory consumption slightly.
> 
> The attached patches must be applied in-order. I would expect them all
> to go via the MFD tree. Alternatively, they could be applied one after
> another during multiple kernel release cycles, but that seems a
> needless complication.
> 
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> ---
> André Draszik (3):
>       mfd: sec: add rtc alarm IRQ as platform device resource
>       rtc: s5m: query platform device IRQ resource for alarm IRQ
>       mfd: sec: drop now unused struct sec_pmic_dev::irq_data
> 
>  drivers/mfd/sec-common.c         | 41 ++++++++++++++++++++++++++++++----------
>  drivers/mfd/sec-core.h           |  2 +-
>  drivers/mfd/sec-irq.c            | 10 ++--------
>  drivers/rtc/rtc-s5m.c            | 21 ++++++++------------
>  include/linux/mfd/samsung/core.h |  1 -
>  5 files changed, 42 insertions(+), 33 deletions(-)

This needs to be rebased now, right?

-- 
Lee Jones [李琼斯]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/3] Samsung mfd/rtc driver alarm IRQ simplification
  2025-11-20 10:31 ` [PATCH 0/3] Samsung mfd/rtc driver alarm IRQ simplification Lee Jones
@ 2025-11-20 10:32   ` André Draszik
  0 siblings, 0 replies; 9+ messages in thread
From: André Draszik @ 2025-11-20 10:32 UTC (permalink / raw)
  To: Lee Jones
  Cc: Krzysztof Kozlowski, Alexandre Belloni, Peter Griffin,
	Tudor Ambarus, Will McVicker, Juan Yescas, Douglas Anderson,
	kernel-team, Kaustabh Chakraborty, linux-kernel,
	linux-samsung-soc, linux-rtc

Hi Lee,

On Thu, 2025-11-20 at 10:31 +0000, Lee Jones wrote:
> On Fri, 14 Nov 2025, André Draszik wrote:
> 
> > Hi,
> > 
> > With the attached patches the Samsung s5m RTC driver is simplified a
> > little bit with regards to alarm IRQ acquisition.
> > 
> > The end result is that instead of having a list of IRQ numbers for each
> > variant (and a BUILD_BUG_ON() to ensure consistency), the RTC driver
> > queries the 'alarm' platform resource from the parent (mfd cell).
> > 
> > Additionally, we can drop a now-useless field from runtime data,
> > reducing memory consumption slightly.
> > 
> > The attached patches must be applied in-order. I would expect them all
> > to go via the MFD tree. Alternatively, they could be applied one after
> > another during multiple kernel release cycles, but that seems a
> > needless complication.
> > 
> > Signed-off-by: André Draszik <andre.draszik@linaro.org>
> > ---
> > André Draszik (3):
> >       mfd: sec: add rtc alarm IRQ as platform device resource
> >       rtc: s5m: query platform device IRQ resource for alarm IRQ
> >       mfd: sec: drop now unused struct sec_pmic_dev::irq_data
> > 
> >  drivers/mfd/sec-common.c         | 41 ++++++++++++++++++++++++++++++----------
> >  drivers/mfd/sec-core.h           |  2 +-
> >  drivers/mfd/sec-irq.c            | 10 ++--------
> >  drivers/rtc/rtc-s5m.c            | 21 ++++++++------------
> >  include/linux/mfd/samsung/core.h |  1 -
> >  5 files changed, 42 insertions(+), 33 deletions(-)
> 
> This needs to be rebased now, right?

Yes, I'll do that now. Thanks for merging the other patch.


Cheers,
Andre'

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/3] mfd: sec: drop now unused struct sec_pmic_dev::irq_data
  2025-11-14 11:47 ` [PATCH 3/3] mfd: sec: drop now unused struct sec_pmic_dev::irq_data André Draszik
@ 2025-11-20 10:35   ` Lee Jones
  2025-11-20 14:38     ` André Draszik
  0 siblings, 1 reply; 9+ messages in thread
From: Lee Jones @ 2025-11-20 10:35 UTC (permalink / raw)
  To: André Draszik
  Cc: Krzysztof Kozlowski, Alexandre Belloni, Peter Griffin,
	Tudor Ambarus, Will McVicker, Juan Yescas, Douglas Anderson,
	kernel-team, Kaustabh Chakraborty, linux-kernel,
	linux-samsung-soc, linux-rtc

On Fri, 14 Nov 2025, André Draszik wrote:

> This was used only to allow the s5m RTC driver to deal with the alarm
> IRQ. That driver now uses a different approach to acquire that IRQ, and
> ::irq_data doesn't need to be kept around anymore.
> 
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> ---
>  drivers/mfd/sec-common.c         |  5 +++--
>  drivers/mfd/sec-core.h           |  2 +-
>  drivers/mfd/sec-irq.c            | 10 ++--------
>  include/linux/mfd/samsung/core.h |  1 -
>  4 files changed, 6 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/mfd/sec-common.c b/drivers/mfd/sec-common.c
> index 77370db52a7ba81234136b29f85892f4b197f429..794c4e5398e7dd1a816aff9a6559a6c19fec75a5 100644
> --- a/drivers/mfd/sec-common.c
> +++ b/drivers/mfd/sec-common.c
> @@ -163,6 +163,7 @@ sec_pmic_parse_dt_pdata(struct device *dev)
>  int sec_pmic_probe(struct device *dev, int device_type, unsigned int irq,
>  		   struct regmap *regmap, struct i2c_client *client)
>  {
> +	struct regmap_irq_chip_data *irq_data;
>  	struct sec_platform_data *pdata;
>  	const struct mfd_cell *sec_devs;
>  	struct sec_pmic_dev *sec_pmic;
> @@ -187,7 +188,7 @@ int sec_pmic_probe(struct device *dev, int device_type, unsigned int irq,
>  
>  	sec_pmic->pdata = pdata;
>  
> -	ret = sec_irq_init(sec_pmic);
> +	ret = sec_irq_init(sec_pmic, &irq_data);
>  	if (ret)
>  		return ret;
>  
> @@ -240,7 +241,7 @@ int sec_pmic_probe(struct device *dev, int device_type, unsigned int irq,
>  				     sec_pmic->device_type);
>  	}
>  	ret = devm_mfd_add_devices(sec_pmic->dev, -1, sec_devs, num_sec_devs,
> -				   NULL, 0, regmap_irq_get_domain(sec_pmic->irq_data));
> +				   NULL, 0, regmap_irq_get_domain(irq_data));
>  	if (ret)
>  		return ret;
>  
> diff --git a/drivers/mfd/sec-core.h b/drivers/mfd/sec-core.h
> index 92c7558ab8b0de44a52e028eeb7998e38358cb4c..c639180ea686f4308af3f872cb1d2209d201b2e7 100644
> --- a/drivers/mfd/sec-core.h
> +++ b/drivers/mfd/sec-core.h
> @@ -18,6 +18,6 @@ int sec_pmic_probe(struct device *dev, int device_type, unsigned int irq,
>  		   struct regmap *regmap, struct i2c_client *client);
>  void sec_pmic_shutdown(struct device *dev);
>  
> -int sec_irq_init(struct sec_pmic_dev *sec_pmic);
> +int sec_irq_init(struct sec_pmic_dev *sec_pmic, struct regmap_irq_chip_data **irq_data);
>  
>  #endif /* __SEC_CORE_INT_H */
> diff --git a/drivers/mfd/sec-irq.c b/drivers/mfd/sec-irq.c
> index c5c80b1ba104e6c5a55b442d2f10a8554201a961..05d4cc350a351d994e00ba08f5ce966d0d5c6a0b 100644
> --- a/drivers/mfd/sec-irq.c
> +++ b/drivers/mfd/sec-irq.c
> @@ -253,7 +253,7 @@ static const struct regmap_irq_chip s5m8767_irq_chip = {
>  	.ack_base = S5M8767_REG_INT1,
>  };
>  
> -int sec_irq_init(struct sec_pmic_dev *sec_pmic)
> +int sec_irq_init(struct sec_pmic_dev *sec_pmic, struct regmap_irq_chip_data **irq_data)

Instead of passing around pointers to pointers, why not return irq_data
or NULL?

>  {
>  	const struct regmap_irq_chip *sec_irq_chip;
>  	int ret;
> @@ -302,17 +302,11 @@ int sec_irq_init(struct sec_pmic_dev *sec_pmic)
>  
>  	ret = devm_regmap_add_irq_chip(sec_pmic->dev, sec_pmic->regmap_pmic,
>  				       sec_pmic->irq, IRQF_ONESHOT,
> -				       0, sec_irq_chip, &sec_pmic->irq_data);
> +				       0, sec_irq_chip, irq_data);
>  	if (ret)
>  		return dev_err_probe(sec_pmic->dev, ret,
>  				     "Failed to add %s IRQ chip\n",
>  				     sec_irq_chip->name);
>  
> -	/*
> -	 * The rtc-s5m driver requests S2MPS14_IRQ_RTCA0 also for S2MPS11
> -	 * so the interrupt number must be consistent.
> -	 */
> -	BUILD_BUG_ON(((enum s2mps14_irq)S2MPS11_IRQ_RTCA0) != S2MPS14_IRQ_RTCA0);
> -
>  	return 0;
>  }
> diff --git a/include/linux/mfd/samsung/core.h b/include/linux/mfd/samsung/core.h
> index d785e101fe795a5d8f9cccf4ccc4232437e89416..c7c3c8cd8d5f99ef0cc3188e1c3b49031f4750f2 100644
> --- a/include/linux/mfd/samsung/core.h
> +++ b/include/linux/mfd/samsung/core.h
> @@ -69,7 +69,6 @@ struct sec_pmic_dev {
>  
>  	int device_type;
>  	int irq;
> -	struct regmap_irq_chip_data *irq_data;
>  };
>  
>  struct sec_platform_data {
> 
> -- 
> 2.52.0.rc1.455.g30608eb744-goog
> 

-- 
Lee Jones [李琼斯]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/3] mfd: sec: drop now unused struct sec_pmic_dev::irq_data
  2025-11-20 10:35   ` Lee Jones
@ 2025-11-20 14:38     ` André Draszik
  0 siblings, 0 replies; 9+ messages in thread
From: André Draszik @ 2025-11-20 14:38 UTC (permalink / raw)
  To: Lee Jones
  Cc: Krzysztof Kozlowski, Alexandre Belloni, Peter Griffin,
	Tudor Ambarus, Will McVicker, Juan Yescas, Douglas Anderson,
	kernel-team, Kaustabh Chakraborty, linux-kernel,
	linux-samsung-soc, linux-rtc

Hi Lee,

On Thu, 2025-11-20 at 10:35 +0000, Lee Jones wrote:
> On Fri, 14 Nov 2025, André Draszik wrote:
> 
> > This was used only to allow the s5m RTC driver to deal with the alarm
> > IRQ. That driver now uses a different approach to acquire that IRQ, and
> > ::irq_data doesn't need to be kept around anymore.
> > 
> > Signed-off-by: André Draszik <andre.draszik@linaro.org>
> > ---
> >  drivers/mfd/sec-common.c         |  5 +++--
> >  drivers/mfd/sec-core.h           |  2 +-
> >  drivers/mfd/sec-irq.c            | 10 ++--------
> >  include/linux/mfd/samsung/core.h |  1 -
> >  4 files changed, 6 insertions(+), 12 deletions(-)
> > 
> > diff --git a/drivers/mfd/sec-common.c b/drivers/mfd/sec-common.c
> > index 77370db52a7ba81234136b29f85892f4b197f429..794c4e5398e7dd1a816aff9a6559a6c19fec75a5 100644
> > --- a/drivers/mfd/sec-common.c
> > +++ b/drivers/mfd/sec-common.c
> > @@ -163,6 +163,7 @@ sec_pmic_parse_dt_pdata(struct device *dev)
> >  int sec_pmic_probe(struct device *dev, int device_type, unsigned int irq,
> >  		   struct regmap *regmap, struct i2c_client *client)
> >  {
> > +	struct regmap_irq_chip_data *irq_data;
> >  	struct sec_platform_data *pdata;
> >  	const struct mfd_cell *sec_devs;
> >  	struct sec_pmic_dev *sec_pmic;
> > @@ -187,7 +188,7 @@ int sec_pmic_probe(struct device *dev, int device_type, unsigned int irq,
> >  
> >  	sec_pmic->pdata = pdata;
> >  
> > -	ret = sec_irq_init(sec_pmic);
> > +	ret = sec_irq_init(sec_pmic, &irq_data);
> >  	if (ret)
> >  		return ret;
> >  
> > @@ -240,7 +241,7 @@ int sec_pmic_probe(struct device *dev, int device_type, unsigned int irq,
> >  				     sec_pmic->device_type);
> >  	}
> >  	ret = devm_mfd_add_devices(sec_pmic->dev, -1, sec_devs, num_sec_devs,
> > -				   NULL, 0, regmap_irq_get_domain(sec_pmic->irq_data));
> > +				   NULL, 0, regmap_irq_get_domain(irq_data));
> >  	if (ret)
> >  		return ret;
> >  
> > diff --git a/drivers/mfd/sec-core.h b/drivers/mfd/sec-core.h
> > index 92c7558ab8b0de44a52e028eeb7998e38358cb4c..c639180ea686f4308af3f872cb1d2209d201b2e7 100644
> > --- a/drivers/mfd/sec-core.h
> > +++ b/drivers/mfd/sec-core.h
> > @@ -18,6 +18,6 @@ int sec_pmic_probe(struct device *dev, int device_type, unsigned int irq,
> >  		   struct regmap *regmap, struct i2c_client *client);
> >  void sec_pmic_shutdown(struct device *dev);
> >  
> > -int sec_irq_init(struct sec_pmic_dev *sec_pmic);
> > +int sec_irq_init(struct sec_pmic_dev *sec_pmic, struct regmap_irq_chip_data **irq_data);
> >  
> >  #endif /* __SEC_CORE_INT_H */
> > diff --git a/drivers/mfd/sec-irq.c b/drivers/mfd/sec-irq.c
> > index c5c80b1ba104e6c5a55b442d2f10a8554201a961..05d4cc350a351d994e00ba08f5ce966d0d5c6a0b 100644
> > --- a/drivers/mfd/sec-irq.c
> > +++ b/drivers/mfd/sec-irq.c
> > @@ -253,7 +253,7 @@ static const struct regmap_irq_chip s5m8767_irq_chip = {
> >  	.ack_base = S5M8767_REG_INT1,
> >  };
> >  
> > -int sec_irq_init(struct sec_pmic_dev *sec_pmic)
> > +int sec_irq_init(struct sec_pmic_dev *sec_pmic, struct regmap_irq_chip_data **irq_data)
> 
> Instead of passing around pointers to pointers, why not return irq_data
> or NULL?

That was mainly to keep change smaller - I've updated the code as per
your suggestion in v2:
https://lore.kernel.org/r/20251120-s5m-alarm-v2-0-cc15f0e32161@linaro.org

Cheers,
Andre'

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-11-20 14:38 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-14 11:47 [PATCH 0/3] Samsung mfd/rtc driver alarm IRQ simplification André Draszik
2025-11-14 11:47 ` [PATCH 1/3] mfd: sec: add rtc alarm IRQ as platform device resource André Draszik
2025-11-14 11:47 ` [PATCH 2/3] rtc: s5m: query platform device IRQ resource for alarm IRQ André Draszik
2025-11-14 15:58   ` Alexandre Belloni
2025-11-14 11:47 ` [PATCH 3/3] mfd: sec: drop now unused struct sec_pmic_dev::irq_data André Draszik
2025-11-20 10:35   ` Lee Jones
2025-11-20 14:38     ` André Draszik
2025-11-20 10:31 ` [PATCH 0/3] Samsung mfd/rtc driver alarm IRQ simplification Lee Jones
2025-11-20 10:32   ` André Draszik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox