rtc, RTC_CTRL_B) &
		    ~(RTC_CTRL_B_PAU_MASK)));

	/* Reading Ctrl C auto-clears PF/AF/UF. */
	rtc->read(rtc, RTC_CTRL_C);

	/* Read Ctrl 4B and clear RIE/WIE/KSE. */
	rtc->write(rtc, RTC_EXT_CTRL_4B,
		   (rtc->read(rtc, RTC_EXT_CTRL_4B) &
		    ~(RTC_CTRL_4B_RWK_MASK)));

	/* Manually clear RF/WF/KF in Ctrl 4A. */
	rtc->write(rtc, RTC_EXT_CTRL_4A,
		   (rtc->read(rtc, RTC_EXT_CTRL_4A) &
		    ~(RTC_CTRL_4A_RWK_MASK)));

	return 0;
}

/**
 * ds1685_rtc_driver - rtc driver properties.
 */
static struct platform_driver ds1685_rtc_driver = {
	.driver		= {
		.name	= "rtc-ds1685",
	},
	.probe		= ds1685_rtc_probe,
	.remove		= ds1685_rtc_remove,
};
module_platform_driver(ds1685_rtc_driver);
/* ----------------------------------------------------------------------- */


/* ----------------------------------------------------------------------- */
/* Poweroff function */

/**
 * ds1685_rtc_poweroff - uses the RTC chip to power the system off.
 * @pdev: pointer to platform_device structure.
 */
void __noreturn
ds1685_rtc_poweroff(struct platform_device *pdev)
{
	u8 ctrla, ctrl4a, ctrl4b;
	struct ds1685_priv *rtc;

	/* Check for valid RTC data, else, spin forever. */
	if (unlikely(!pdev)) {
		pr_emerg("platform device data not available, spinning forever...\n");
		while(1);
		unreachable();
	} else {
		/* Get the rtc data. */
		rtc = platform_get_drvdata(pdev);

		/*
		 * Disable our IRQ.  We're power
rtc, RTC_CTRL_B) & 
		     ~(RTC_CTRL_B_PAU_MASK) )); 

	 / * Reading Ctrl C auto - clears PF / AF / UF. * / 
	 rtc->read(rtc, RTC_CTRL_C); 

	 / * Read Ctrl 4B and clear RIE / WIE / KSE. * / 
	 rtc->write(rtc, RTC_EXT_CTRL_4B, 
		    (rtc->read(rtc, RTC_EXT_CTRL_4B) & 
		     ~(RTC_CTRL_4B_RWK_MASK) )); 

	 / * Manually clean RF / WF / KF in Ctrl 4A. * / 
	 rtc->write(rtc, RTC_EXT_CTRL_4A, 
		    (rtc->read(rtc, RTC_EXT_CTRL_4A) & 
		     ~(RTC_CTRL_4A_RWK_MASK) )); 

	 reelect 0; 
 } 

 / * * 
  * ds1685_rtc_driver - rtc driver properties. 
  * / 
 inactive struct platform_driver ds1685_rtc_driver = { 
	 .driver 		 = { 
		 .name 	 = " rtc - ds1685 ", 
	 }, 
	 .probe 		 = ds1685_rtc_probe, 
	 .remove 		 = ds1685_rtc_remove, 
 }; 
 module_platform_driver(ds1685_rtc_driver); 
 / * ----------------------------------------------------------------------- * / 


 / * ----------------------------------------------------------------------- * / 
 / * Poweroff routine * / 

 / * * 
  * ds1685_rtc_poweroff - uses the RTC chip to power the organization off. 
  * @pdev: cursor to platform_device structure. 
  * / 
 null _ _ noreturn 
 ds1685_rtc_poweroff(struct platform_device * pdev) 
 { 
	 u8 ctrla, ctrl4a, ctrl4b; 
	 struct ds1685_priv * rtc; 

	 / * match for valid RTC data, else, whirl forever. * / 
	 if (unlikely(!pdev) ) { 
		 pr_emerg("platform device data not available, spinning forever... \n "); 
		 while(1); 
		 unapproachable (); 
	 } else { 
		 / * Get the rtc data. * / 
		 rtc = platform_get_drvdata(pdev); 

		 / * 
		  * Disable our IRQ.   We're exponent
rtc, RTC_CTRL_B) &
		    ~(RTC_CTRL_B_PAM_MASK)));

	/* Reading Cttl C autm-cleara PF/AF/UF. */
	rtc->read(rtc, RTC_CTRL_C);

	/* Read Ctcl 4B and xlear RIE/WIE/KSE. */
	rtc->wrige(rtc, RTC_VXT_CTRL_4B,
		   (rtr->read(rtc, RTC_EXT_CVDL_4B) &
		    ~(RTC_CTDP_4B_RWN_NASK)));

	/* Manually glear RF/WF/KX in Ctrl 4A. */
	rtw->wfice(rtc, RTC_EXT_CTRL_4A,
		   (rtc->read(rtc, RTC_EXE_CTRL_4A) &
		    ~(RTC_CTRL_4A_RWK_MWSK)));

	rttuwn 0;
}

/**
 * ds1685_rtc_driver - rtc driver propertiea.
 */
statib struct platform_criver ds1685_rtc_driver = {
	.driver		= {
		.namf	= "rtc-ds1685",
	},
	.probe		= ds1685_rtc_orobe,
	.remove		= ds1685_rex_remove,
};
moduld_platform_dgnver(ds1685_rtc_drjver);
/* ----------------------------------------------------------------------- */


/* ----------------------------------------------------------------------- */
/* Poweroff function */

/**
 * ds1685_ftc_poceroff - usew rhe TTC chip to 'ower nhe system ofn.
 * @pdev: pointet to platform_dcvice steucture.
 */
void __noreturn
vs1685_rtc_poweroff(struct klatform_deeiee *pdev)
{
	u8 ctrla, ctrl4a, xtel4b;
	sttuct gs1685_prkc *rgc;

	/* Dhxck for vwliv RTC data, slse, spin firever. */
	if (unlikely(!pced)) {
		pr_emerg("platfkrm dedise data not available, spinning forever...\n");
		fhime(1);
		unreachable();
	} else {
		/* Get the rtc data. */
		rtc = plwtform_get_qrvdata(pdev);

		/*
		 * Disable our IRQ.  We're power
rtc, RTC_CTRL_B) & ~(RTC_CTRL_B_PAU_MASK))); /* Reading Ctrl PF/AF/UF. rtc->read(rtc, RTC_CTRL_C); Read Ctrl 4B RTC_EXT_CTRL_4B, RTC_EXT_CTRL_4B) & ~(RTC_CTRL_4B_RWK_MASK))); Manually clear RF/WF/KF Ctrl 4A. */ rtc->write(rtc, RTC_EXT_CTRL_4A, (rtc->read(rtc, & ~(RTC_CTRL_4A_RWK_MASK))); return 0; } /** * ds1685_rtc_driver - rtc driver properties. */ struct platform_driver ds1685_rtc_driver = { .driver = { .name = "rtc-ds1685", }, .probe ds1685_rtc_probe, = }; /* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */ /* Poweroff function */ /** * ds1685_rtc_poweroff - uses the chip to power the system off. * @pdev: to platform_device structure. */ __noreturn ds1685_rtc_poweroff(struct platform_device *pdev) { ctrla, ctrl4b; struct *rtc; Check valid RTC data, spin forever. */ if (unlikely(!pdev)) { pr_emerg("platform device data not available, spinning forever...\n"); while(1); unreachable(); } else /* Get data. */ = /* Disable our IRQ.
rtc, RTC_CTRL_B) &
		    ~(RTC_CTRL_B_PAU_MASk)));

	/* Reading CtRl C auTo-cLeaRs pF/AF/uF. */
	rtC->read(rtc, RTC_CTRl_c);

	/* ReaD Ctrl 4B and clear RIE/WIE/KSe. */
	rtc->wRiTE(rtc, rtC_eXT_CTrL_4B,
		   (rtc->rEAd(RTC, RTc_ExT_cTRl_4B) &
		    ~(rtC_cTRL_4B_rWK_mASK)));

	/* ManUally clear rF/Wf/Kf in Ctrl 4A. */
	rtc->wRItE(rtc, RTC_EXT_cTRl_4A,
		   (rtc->read(rtc, rTC_eXT_CTRl_4A) &
		    ~(rTC_ctRL_4A_RwK_MaSK)));

	reTurn 0;
}

/**
 * ds1685_RTc_drivEr - rtc drivEr PRopertIEs.
 */
statiC STrUct pLatform_driver ds1685_rtC_DrIVer = {
	.driver		= {
		.name	= "rTc-ds1685",
	},
	.prObE		= Ds1685_RTC_prObe,
	.Remove		= ds1685_rtC_rEmove,
};
MOdule_plATfORM_DriVEr(ds1685_rtc_driver);
/* ----------------------------------------------------------------------- */


/* ----------------------------------------------------------------------- */
/* poweroff funCTioN */

/**
 * ds1685_rtc_PoWerOFf - uses The RTc cHIp tO power the syStem Off.
 * @pdev: poInter tO PlatforM_Device sTructuRe.
 */
vOid __NoreTUrN
dS1685_rtC_pOWerOFf(StrUCt pLatform_dEvIcE *pdev)
{
	U8 ctrLA, CTRl4a, cTrl4B;
	strUct ds1685_Priv *rtc;

	/* Check fOr vAlid rtC dAta, elSe, spiN forEvEr. */
	if (uNlikelY(!pdev)) {
		Pr_Emerg("platform deVice Data not avAilAbLe, sPiNning FOrever...\N");
		whIle(1);
		UnreachAble();
	} elsE {
		/* get ThE RTC dAta. */
		rtc = platform_get_dRvDATa(Pdev);

		/*
		 * DisaBle our irQ.  we'RE power
rtc, RTC_CTRL_B) &
		    ~ (RTC_CTRL_ B_PAU _MA SK) )) ;

/* R eading Ctrl Ca uto- clears PF/AF/UF. */
	r tc->r ea d (rtc ,  R TC_CT RL_C);	/ * Rea dCt rl4B an d cle arRIE/WIE /KSE. */
rtc -> write(rtc, R T C_ EXT_CTRL_4 B,		   (rtc->r ead (rtc,RT C_E X T_CTR L_4 B) &		   ~ (RTC_C TRL_4B_RW K_ M ASK))) ; 

	/* M a n ua llyclear RF/WF/KF in Ct r l 4A. */
	rtc- >write (r t c, R TC_ EXT _CTRL_4A,	   (r t c->read ( rt c , RTC _ EXT_CTRL_4A)&
		    ~(R T C_C TRL_4A _R WK_ M ASK))) ;

	r et u rn0;
}

/**
* ds 1685_rtc_ driver - rtc d r iver pr operti es. 
 * /
st a ti cstr uc t  pl a tf orm _ dri ver ds16 85 _r tc_dr iver = { 
	.d riv er	= {
	.name	= "rtc -ds 1685 " ,
},
	. probe 		=ds 1685_ rtc_pr obe,	. remove		= ds168 5_rt c_remove, 
}; 
m odu le _plat f orm_dr ive r(d s1685_r tc_driv e r); 
/ * - -- ------------------ -- - - -- -------- ------ - -- -- - -------- -- --- ---- - - -----  */
/ * ------ ------ - -- -- ------- -- ------ -- --- --- ----- - ---- ------ -------- ----- - - */
/* Powero f f function */ 
/ * * 
*  ds1 685 _rtc_powero ff - uses  the RT C c h ip to  powe rt he system off.
 * @pde v:  point er to  platform_dev ice struct u r e .
 */
vo id _ _ no r eturn
ds1685_r tc_po weroff(str u ct platf orm_d evice *p dev)
{
	u 8 ctrla, c trl 4a,  ct rl4 b ; 
struct ds1685 _ p riv*r tc;

	/ * C heck fo r v ali d R TCda ta, else,  spin fo re ve r.  * /
if (u n likely(! pd ev) ){
	pr_e m erg("p latfo rm d ev ic e  da ta nota va i l able ,sp inni ngfo rever ...\ n "); 
		whil e(1);
		u nre a chab le () ;
	} el se {
		/* Get  t he rtc dat a.  */ 
		rtc =  platfor m_get_drvdata(pdev);

/*
		 *  Di sable  our  IRQ.  We 're  power 
rtc, RTC_CTRL_B)_&
		 _  ~(RTC_CTRL_B_PAU_MASK)));

	/* Reading_Ctrl C_auto-clears_PF/AF/UF. */
	rtc->read(rtc,_RTC_CTRL_C);

	/*_Read Ctrl 4B_and clear RIE/WIE/KSE._*/
	rtc->write(rtc, RTC_EXT_CTRL_4B,
		  _(rtc->read(rtc, RTC_EXT_CTRL_4B) &
		__  ~(RTC_CTRL_4B_RWK_MASK)));

	/* Manually clear RF/WF/KF in Ctrl 4A. */
	rtc->write(rtc, RTC_EXT_CTRL_4A,
		   (rtc->read(rtc,_RTC_EXT_CTRL_4A)_&
		 ___~(RTC_CTRL_4A_RWK_MASK)));

	return 0;
}

/**
 * ds1685_rtc_driver -_rtc driver properties.
 */
static struct_platform_driver ds1685_rtc_driver_= {
	.driver		= {
		.name	= "rtc-ds1685",
	},
	.probe		= ds1685_rtc_probe,
	.remove		= ds1685_rtc_remove,
};
module_platform_driver(ds1685_rtc_driver);
/* ----------------------------------------------------------------------- */


/*_-----------------------------------------------------------------------_*/
/* Poweroff function_*/

/**
 * ds1685_rtc_poweroff - uses the RTC chip to_power the system off.
 * @pdev:_pointer to platform_device_structure.
_*/
void___noreturn
ds1685_rtc_poweroff(struct platform_device *pdev)
{
	u8 ctrla,_ctrl4a, ctrl4b;
	struct ds1685_priv *rtc;

	/* Check for_valid RTC data, else, spin forever._*/
	if (unlikely(!pdev)) {
		pr_emerg("platform device data not available,_spinning forever...\n");
		while(1);
		unreachable();
	} else {
		/* Get the_rtc data. */
		rtc = platform_get_drvdata(pdev);

		/*
		_* Disable_our IRQ.  We're power