Skip to content

Commit a50f00c

Browse files
Wolfram Sangalexandrebelloni
authored andcommitted
rtc: rzn1: Disable controller before initialization
Datasheet says that the controller must be disabled before setting up either SUBU or SCMP. This did not matter so far because the driver only supported SUBU which was the default, too. It is good practice to follow datasheet recommendations, though. It will also be needed because SCMP mode will be added in a later patch. Signed-off-by: Wolfram Sang <[email protected]> Reviewed-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Belloni <[email protected]>
1 parent ae95a7e commit a50f00c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/rtc/rtc-rzn1.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#define RZN1_RTC_CTL0_SLSB_SUBU 0
2626
#define RZN1_RTC_CTL0_SLSB_SCMP BIT(4)
2727
#define RZN1_RTC_CTL0_AMPM BIT(5)
28+
#define RZN1_RTC_CTL0_CEST BIT(6)
2829
#define RZN1_RTC_CTL0_CE BIT(7)
2930

3031
#define RZN1_RTC_CTL1 0x04
@@ -369,6 +370,7 @@ static const struct rtc_class_ops rzn1_rtc_ops = {
369370
static int rzn1_rtc_probe(struct platform_device *pdev)
370371
{
371372
struct rzn1_rtc *rtc;
373+
u32 val;
372374
int irq;
373375
int ret;
374376

@@ -406,6 +408,14 @@ static int rzn1_rtc_probe(struct platform_device *pdev)
406408
* Ensure the clock counter is enabled.
407409
* Set 24-hour mode and possible oscillator offset compensation in SUBU mode.
408410
*/
411+
val = readl(rtc->base + RZN1_RTC_CTL0) & ~RZN1_RTC_CTL0_CE;
412+
writel(val, rtc->base + RZN1_RTC_CTL0);
413+
/* Wait 2-4 32k clock cycles for the disabled controller */
414+
ret = readl_poll_timeout(rtc->base + RZN1_RTC_CTL0, val,
415+
!(val & RZN1_RTC_CTL0_CEST), 62, 123);
416+
if (ret)
417+
goto dis_runtime_pm;
418+
409419
writel(RZN1_RTC_CTL0_CE | RZN1_RTC_CTL0_AMPM | RZN1_RTC_CTL0_SLSB_SUBU,
410420
rtc->base + RZN1_RTC_CTL0);
411421

0 commit comments

Comments
 (0)