public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] rtc: max77686: convert to i2c_new_ancillary_device
@ 2026-02-23  6:43 Svyatoslav Ryhel
  2026-02-23  6:43 ` [PATCH v2 1/2] dt-bindings: mfd: max77620: document optional RTC address for max77663 Svyatoslav Ryhel
  2026-02-23  6:43 ` [PATCH v2 2/2] rtc: max77686: convert to i2c_new_ancillary_device Svyatoslav Ryhel
  0 siblings, 2 replies; 4+ messages in thread
From: Svyatoslav Ryhel @ 2026-02-23  6:43 UTC (permalink / raw)
  To: Chanwoo Choi, Krzysztof Kozlowski, Lee Jones, Rob Herring,
	Conor Dooley, Alexandre Belloni, Svyatoslav Ryhel
  Cc: linux-kernel, devicetree, linux-rtc

Convert RTC I2C device creation from devm_i2c_new_dummy_device() to
i2c_new_ancillary_device() to enable the use of a device tree-specified
RTC address instead of a hardcoded value. If the device tree does not
provide an address, use hardcoded values as a fallback.

This addresses an issue with the MAX77663 PMIC, which can have the RTC at
different I2C positions (either 0x48, like the MAX77714, or 0x68, like
the MAX77620). The MAX77620 value is used as the default. The I2C position
of the MAX77663 is factory-set and cannot be detected from the chip
itself.

I have tested this patch on LG Optimus Vu P895 with max77663 PMIC and
non-default RTC position. RTC is registered correctly.

---
Changes in v2
- dropped patch that changes max77686 and adjusted max77620 where max77663
  is described.
---

Svyatoslav Ryhel (2):
  dt-bindings: mfd: max77620: document optional RTC address for max77663
  rtc: max77686: convert to i2c_new_ancillary_device

 Documentation/devicetree/bindings/mfd/max77620.txt |  4 +++-
 drivers/rtc/rtc-max77686.c                         | 14 ++++++++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)

-- 
2.51.0


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

* [PATCH v2 1/2] dt-bindings: mfd: max77620: document optional RTC address for max77663
  2026-02-23  6:43 [PATCH v2 0/2] rtc: max77686: convert to i2c_new_ancillary_device Svyatoslav Ryhel
@ 2026-02-23  6:43 ` Svyatoslav Ryhel
  2026-03-05 23:56   ` Rob Herring
  2026-02-23  6:43 ` [PATCH v2 2/2] rtc: max77686: convert to i2c_new_ancillary_device Svyatoslav Ryhel
  1 sibling, 1 reply; 4+ messages in thread
From: Svyatoslav Ryhel @ 2026-02-23  6:43 UTC (permalink / raw)
  To: Chanwoo Choi, Krzysztof Kozlowski, Lee Jones, Rob Herring,
	Conor Dooley, Alexandre Belloni, Svyatoslav Ryhel
  Cc: linux-kernel, devicetree, linux-rtc

Document an optional second I2C address for the MAX77663 PMIC's RTC
device, to be used if the MAX77663 RTC is located at a non-default I2C
address.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 Documentation/devicetree/bindings/mfd/max77620.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/mfd/max77620.txt b/Documentation/devicetree/bindings/mfd/max77620.txt
index 5a642a51d58e..0bbb42e5dcfe 100644
--- a/Documentation/devicetree/bindings/mfd/max77620.txt
+++ b/Documentation/devicetree/bindings/mfd/max77620.txt
@@ -6,10 +6,12 @@ Required properties:
 		"maxim,max77620"
 		"maxim,max20024"
 		"maxim,max77663"
-- reg: I2C device address.
+- reg: I2C device address. In case of MAX77663 there can be 2 addresses,
+       second one specifies position of RTC.
 
 Optional properties:
 -------------------
+- reg-names:		If 2 addresses are specified then, must be "pmic", "rtc"
 - interrupts:		The interrupt on the parent the controller is
 			connected to.
 - interrupt-controller: Marks the device node as an interrupt controller.
-- 
2.51.0


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

* [PATCH v2 2/2] rtc: max77686: convert to i2c_new_ancillary_device
  2026-02-23  6:43 [PATCH v2 0/2] rtc: max77686: convert to i2c_new_ancillary_device Svyatoslav Ryhel
  2026-02-23  6:43 ` [PATCH v2 1/2] dt-bindings: mfd: max77620: document optional RTC address for max77663 Svyatoslav Ryhel
@ 2026-02-23  6:43 ` Svyatoslav Ryhel
  1 sibling, 0 replies; 4+ messages in thread
From: Svyatoslav Ryhel @ 2026-02-23  6:43 UTC (permalink / raw)
  To: Chanwoo Choi, Krzysztof Kozlowski, Lee Jones, Rob Herring,
	Conor Dooley, Alexandre Belloni, Svyatoslav Ryhel
  Cc: linux-kernel, devicetree, linux-rtc

Convert RTC I2C device creation from devm_i2c_new_dummy_device() to
i2c_new_ancillary_device() to enable the use of a device tree-specified
RTC address instead of a hardcoded value. If the device tree does not
provide an address, use hardcoded values as a fallback.

This addresses an issue with the MAX77663 PMIC, which can have the RTC at
different I2C positions (either 0x48, like the MAX77714, or 0x68, like
the MAX77620). The MAX77620 value is used as the default. The I2C position
of the MAX77663 is factory-set and cannot be detected from the chip
itself.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 drivers/rtc/rtc-max77686.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-max77686.c b/drivers/rtc/rtc-max77686.c
index 69ea3ce75b5a..3cdfd78a07cc 100644
--- a/drivers/rtc/rtc-max77686.c
+++ b/drivers/rtc/rtc-max77686.c
@@ -686,6 +686,11 @@ static int max77686_rtc_init_reg(struct max77686_rtc_info *info)
 	return ret;
 }
 
+static void max77686_rtc_release_dev(void *client)
+{
+	i2c_unregister_device(client);
+}
+
 static int max77686_init_rtc_regmap(struct max77686_rtc_info *info)
 {
 	struct device *parent = info->dev->parent;
@@ -713,12 +718,17 @@ static int max77686_init_rtc_regmap(struct max77686_rtc_info *info)
 		goto add_rtc_irq;
 	}
 
-	client = devm_i2c_new_dummy_device(info->dev, parent_i2c->adapter,
-					   info->drv_data->rtc_i2c_addr);
+	client = i2c_new_ancillary_device(parent_i2c, "rtc",
+					  info->drv_data->rtc_i2c_addr);
 	if (IS_ERR(client))
 		return dev_err_probe(info->dev, PTR_ERR(client),
 				     "Failed to allocate I2C device for RTC\n");
 
+	ret = devm_add_action_or_reset(info->dev, max77686_rtc_release_dev,
+				       client);
+	if (ret)
+		return ret;
+
 	info->rtc_regmap = devm_regmap_init_i2c(client,
 						info->drv_data->regmap_config);
 	if (IS_ERR(info->rtc_regmap))
-- 
2.51.0


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

* Re: [PATCH v2 1/2] dt-bindings: mfd: max77620: document optional RTC address for max77663
  2026-02-23  6:43 ` [PATCH v2 1/2] dt-bindings: mfd: max77620: document optional RTC address for max77663 Svyatoslav Ryhel
@ 2026-03-05 23:56   ` Rob Herring
  0 siblings, 0 replies; 4+ messages in thread
From: Rob Herring @ 2026-03-05 23:56 UTC (permalink / raw)
  To: Svyatoslav Ryhel
  Cc: Chanwoo Choi, Krzysztof Kozlowski, Lee Jones, Conor Dooley,
	Alexandre Belloni, linux-kernel, devicetree, linux-rtc

On Mon, Feb 23, 2026 at 08:43:42AM +0200, Svyatoslav Ryhel wrote:
> Document an optional second I2C address for the MAX77663 PMIC's RTC
> device, to be used if the MAX77663 RTC is located at a non-default I2C
> address.

No changes to .txt bindings. Convert to schema first if you have 
additions.

> 
> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> ---
>  Documentation/devicetree/bindings/mfd/max77620.txt | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/mfd/max77620.txt b/Documentation/devicetree/bindings/mfd/max77620.txt
> index 5a642a51d58e..0bbb42e5dcfe 100644
> --- a/Documentation/devicetree/bindings/mfd/max77620.txt
> +++ b/Documentation/devicetree/bindings/mfd/max77620.txt
> @@ -6,10 +6,12 @@ Required properties:
>  		"maxim,max77620"
>  		"maxim,max20024"
>  		"maxim,max77663"
> -- reg: I2C device address.
> +- reg: I2C device address. In case of MAX77663 there can be 2 addresses,
> +       second one specifies position of RTC.
>  
>  Optional properties:
>  -------------------
> +- reg-names:		If 2 addresses are specified then, must be "pmic", "rtc"
>  - interrupts:		The interrupt on the parent the controller is
>  			connected to.
>  - interrupt-controller: Marks the device node as an interrupt controller.
> -- 
> 2.51.0
> 

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

end of thread, other threads:[~2026-03-05 23:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-23  6:43 [PATCH v2 0/2] rtc: max77686: convert to i2c_new_ancillary_device Svyatoslav Ryhel
2026-02-23  6:43 ` [PATCH v2 1/2] dt-bindings: mfd: max77620: document optional RTC address for max77663 Svyatoslav Ryhel
2026-03-05 23:56   ` Rob Herring
2026-02-23  6:43 ` [PATCH v2 2/2] rtc: max77686: convert to i2c_new_ancillary_device Svyatoslav Ryhel

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