public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] max77663-rtc: pass rtc address from device tree node if exists
@ 2023-03-08  8:37 Svyatoslav Ryhel
  2023-03-08  8:44 ` Alexandre Belloni
  2023-03-08  8:54 ` Krzysztof Kozlowski
  0 siblings, 2 replies; 14+ messages in thread
From: Svyatoslav Ryhel @ 2023-03-08  8:37 UTC (permalink / raw)
  To: Chanwoo Choi, Krzysztof Kozlowski, Alessandro Zummo,
	Alexandre Belloni, Svyatoslav Ryhel
  Cc: linux-kernel, linux-rtc

MAX77663 PMIC can have RTC on both 0x63 i2c address (like grouper)
which is main address but on some devices RTC is located on 0x48
i2c address (like p880 and p895 from LG). Lets add property to be
able to use alternative address if needed without breaking existing
bindings.

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

diff --git a/drivers/rtc/rtc-max77686.c b/drivers/rtc/rtc-max77686.c
index b0250d91fb00..218177375531 100644
--- a/drivers/rtc/rtc-max77686.c
+++ b/drivers/rtc/rtc-max77686.c
@@ -691,6 +691,7 @@ static int max77686_init_rtc_regmap(struct max77686_rtc_info *info)
 {
 	struct device *parent = info->dev->parent;
 	struct i2c_client *parent_i2c = to_i2c_client(parent);
+	int rtc_i2c_addr;
 	int ret;
 
 	if (info->drv_data->rtc_irq_from_platform) {
@@ -714,8 +715,13 @@ static int max77686_init_rtc_regmap(struct max77686_rtc_info *info)
 		goto add_rtc_irq;
 	}
 
+	ret = device_property_read_u32(parent, "maxim,rtc-i2c-address",
+				       &rtc_i2c_addr);
+	if (ret)
+		rtc_i2c_addr = info->drv_data->rtc_i2c_addr;
+
 	info->rtc = devm_i2c_new_dummy_device(info->dev, parent_i2c->adapter,
-					      info->drv_data->rtc_i2c_addr);
+					      rtc_i2c_addr);
 	if (IS_ERR(info->rtc)) {
 		dev_err(info->dev, "Failed to allocate I2C device for RTC\n");
 		return PTR_ERR(info->rtc);
-- 
2.37.2


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

end of thread, other threads:[~2023-03-08 10:49 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-08  8:37 [PATCH v1] max77663-rtc: pass rtc address from device tree node if exists Svyatoslav Ryhel
2023-03-08  8:44 ` Alexandre Belloni
2023-03-08  8:46   ` Svyatoslav Ryhel
2023-03-08  8:49     ` Krzysztof Kozlowski
2023-03-08  8:51       ` Svyatoslav Ryhel
2023-03-08  8:55         ` Krzysztof Kozlowski
2023-03-08  8:54 ` Krzysztof Kozlowski
2023-03-08  8:58   ` Svyatoslav Ryhel
2023-03-08  9:11     ` Krzysztof Kozlowski
2023-03-08  9:14       ` Krzysztof Kozlowski
2023-03-08  9:42         ` Alexandre Belloni
2023-03-08 10:49           ` Krzysztof Kozlowski
2023-03-08  9:29       ` Svyatoslav Ryhel
2023-03-08 10:46         ` Krzysztof Kozlowski

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