+
+#if defined(CONFIG_SYS_RV3029_TCR)
+ /*
+ * because EEPROM_CTRL register is in EEPROM page it is necessary to
+ * disable automatic EEPROM refresh and check if EEPROM is busy
+ * before EEPORM_CTRL register may be accessed
+ */
+ set_eere_bit(0);
+ wait_eebusy(100);
+ /* read current trickle charger setting */
+ (void)i2c_read(CONFIG_SYS_I2C_RTC_ADDR, RTC_RV3029_EEPROM_CTRL,
+ 1, buf, 1);
+ /* enable automatic EEPROM refresh again */
+ set_eere_bit(1);
+
+ /*
+ * to minimize EEPROM access write trickle charger setting only if it
+ * differs from current value
+ */
+ if ((buf[0] & 0xF0) != CONFIG_SYS_RV3029_TCR) {
+ buf[0] = (buf[0] & 0x0F) | CONFIG_SYS_RV3029_TCR;
+ /*
+ * write trickle charger setting (disable autom. EEPROM
+ * refresh and wait until EEPROM is idle)
+ */
+ set_eere_bit(0);
+ wait_eebusy(100);
+ (void)i2c_write(CONFIG_SYS_I2C_RTC_ADDR,
+ RTC_RV3029_EEPROM_CTRL, 1, buf, 1);
+ /*
+ * it is necessary to wait 10ms before EEBUSY-Bit may be read
+ * (this is not documented in the data sheet yet, but the
+ * manufacturer recommends it)
+ */
+ udelay(10000);
+ /* wait until EEPROM write access is finished */
+ wait_eebusy(100);
+ set_eere_bit(1);
+ }
+#endif