Skip to content

Commit 0d65a9d

Browse files
clamor-salexandrebelloni
authored andcommitted
rtc: max77686: convert to i2c_new_ancillary_device
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> Link: https://patch.msgid.link/20260312085258.11431-6-clamor95@gmail.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
1 parent cbf39bf commit 0d65a9d

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

drivers/rtc/rtc-max77686.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,11 @@ static int max77686_rtc_init_reg(struct max77686_rtc_info *info)
686686
return ret;
687687
}
688688

689+
static void max77686_rtc_release_dev(void *client)
690+
{
691+
i2c_unregister_device(client);
692+
}
693+
689694
static int max77686_init_rtc_regmap(struct max77686_rtc_info *info)
690695
{
691696
struct device *parent = info->dev->parent;
@@ -713,12 +718,17 @@ static int max77686_init_rtc_regmap(struct max77686_rtc_info *info)
713718
goto add_rtc_irq;
714719
}
715720

716-
client = devm_i2c_new_dummy_device(info->dev, parent_i2c->adapter,
717-
info->drv_data->rtc_i2c_addr);
721+
client = i2c_new_ancillary_device(parent_i2c, "rtc",
722+
info->drv_data->rtc_i2c_addr);
718723
if (IS_ERR(client))
719724
return dev_err_probe(info->dev, PTR_ERR(client),
720725
"Failed to allocate I2C device for RTC\n");
721726

727+
ret = devm_add_action_or_reset(info->dev, max77686_rtc_release_dev,
728+
client);
729+
if (ret)
730+
return ret;
731+
722732
info->rtc_regmap = devm_regmap_init_i2c(client,
723733
info->drv_data->regmap_config);
724734
if (IS_ERR(info->rtc_regmap))

0 commit comments

Comments
 (0)