linux-4.14.90-dev/linux-4.14.90/drivers/rtc/rtc-ds1685.c
/**
 * ds1685_rtc_begin_data_access - prepare the rtc for data access.
 * @rtc: pointer to the ds1685 rtc structure.
 *
 * This takes several steps to prepare the rtc for access to get/set time
 * and alarm values from the rtc registers:
 *  - Sets the SET bit in Control Register B.
 *  - Reads Ext Control Register 4A and checks the INCR bit.
 *  - If INCR is active, a short delay is added before Ext Control Register 4A
 *    is read again in a loop until INCR is inactive.
 *  - Switches the rtc to bank 1.  This allows access to all relevant
 *    data for normal rtc operation, as bank 0 contains only the nvram.
 */
prepare the rtc for data access.
@rtc: pointer to the ds1685 rtc structure.

This takes several steps to prepare the rtc for access to get/set time
and alarm values from the rtc registers:
- Sets the SET bit in Control Register B.
- Reads Ext Control Register 4A and checks the INCR bit.
- If INCR is active, a short delay is added before Ext Control Register 4A
is read again in a loop until INCR is inactive.
- Switches the rtc to bank 1.  This allows access to all relevant
data for normal rtc operation, as bank 0 contains only the nvram.
prepare the rtc for data access . @rtc : pointer to the ds1685 rtc structure . This takes several steps to prepare the rtc for access to get / set time and alarm values from the rtc registers : - Sets the SET bit in Control Register B . - Reads Ext Control Register 4A and checks the INCR bit . - If INCR is active a short delay is added before Ext Control Register 4A is read again in a loop until INCR is inactive . - Switches the rtc to bank 1 . This allows access to all relevant data for normal rtc operation as bank 0 contains only the nvram .
static inline void
ds1685_rtc_begin_data_access(struct ds1685_priv *rtc)
{
	rtc->write(rtc, RTC_CTRL_B,
		   (rtc->read(rtc, RTC_CTRL_B) | RTC_CTRL_B_SET));
	while (rtc->read(rtc, RTC_EXT_CTRL_4A) & RTC_CTRL_4A_INCR)
		cpu_relax();
	ds1685_rtc_switch_to_bank1(rtc);
}
static inline void ds1685_rtc_begin_data_access ( struct ds1685_priv * rtc ) { rtc -> write ( rtc , RTC_CTRL_B , ( rtc -> read ( rtc , RTC_CTRL_B ) | RTC_CTRL_B_SET ) ) ; while ( rtc -> read ( rtc , RTC_EXT_CTRL_4A ) & RTC_CTRL_4A_INCR ) cpu_relax ( ) ; ds1685_rtc_switch_to_bank1 ( rtc ) ; }
ds1685_rtc_begin_data_access - prepare the rtc for data access.
ds1685_rtc_begin_data_access - prepare the rtc for data access .
/* Set the SET bit in Ctrl B */ /* Read Ext Ctrl 4A and check the INCR bit to avoid a lockout. */ /* Switch to Bank 1 */