From: Bartosz Golaszewski <brgl@bgdev•pl>
To: Sekhar Nori <nsekhar@ti•com>,
Daniel Lezcano <daniel.lezcano@linaro•org>,
Thomas Gleixner <tglx@linutronix•de>,
David Lechner <david@lechnology•com>,
Kevin Hilman <khilman@kernel•org>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre•com>,
linux-kernel@vger•kernel.org,
linux-arm-kernel@lists•infradead.org
Subject: [PATCH v2 1/3] clocksource: davinci: only enable tim34 in periodic mode once it's initialized
Date: Tue, 24 Dec 2019 11:03:26 +0100 [thread overview]
Message-ID: <20191224100328.13608-2-brgl@bgdev.pl> (raw)
In-Reply-To: <20191224100328.13608-1-brgl@bgdev.pl>
From: Bartosz Golaszewski <bgolaszewski@baylibre•com>
The DM365 platform has a strange quirk (only present when using ancient
u-boot - mainline u-boot v2013.01 and later works fine) where if we
enable the second half of the timer in periodic mode before we do its
initialization - the time won't start flowing and we can't boot.
When using more recent u-boot, we can enable the timer, then reinitialize
it and all works fine.
I've been unable to figure out why that is, but a workaround for this
is straightforward - don't enable the tim34 timer in periodic mode until
it's properly initialized.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre•com>
---
drivers/clocksource/timer-davinci.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/clocksource/timer-davinci.c b/drivers/clocksource/timer-davinci.c
index 62745c962049..2801f21bb0e2 100644
--- a/drivers/clocksource/timer-davinci.c
+++ b/drivers/clocksource/timer-davinci.c
@@ -62,6 +62,7 @@ static struct {
struct clocksource dev;
void __iomem *base;
unsigned int tim_off;
+ bool initialized;
} davinci_clocksource;
static struct davinci_clockevent *
@@ -94,8 +95,9 @@ static void davinci_tim12_shutdown(void __iomem *base)
* halves. In this case TIM34 runs in periodic mode and we must
* not modify it.
*/
- tcr |= DAVINCI_TIMER_ENAMODE_PERIODIC <<
- DAVINCI_TIMER_ENAMODE_SHIFT_TIM34;
+ if (likely(davinci_clocksource.initialized))
+ tcr |= DAVINCI_TIMER_ENAMODE_PERIODIC <<
+ DAVINCI_TIMER_ENAMODE_SHIFT_TIM34;
writel_relaxed(tcr, base + DAVINCI_TIMER_REG_TCR);
}
@@ -107,8 +109,9 @@ static void davinci_tim12_set_oneshot(void __iomem *base)
tcr = DAVINCI_TIMER_ENAMODE_ONESHOT <<
DAVINCI_TIMER_ENAMODE_SHIFT_TIM12;
/* Same as above. */
- tcr |= DAVINCI_TIMER_ENAMODE_PERIODIC <<
- DAVINCI_TIMER_ENAMODE_SHIFT_TIM34;
+ if (likely(davinci_clocksource.initialized))
+ tcr |= DAVINCI_TIMER_ENAMODE_PERIODIC <<
+ DAVINCI_TIMER_ENAMODE_SHIFT_TIM34;
writel_relaxed(tcr, base + DAVINCI_TIMER_REG_TCR);
}
@@ -206,6 +209,8 @@ static void davinci_clocksource_init_tim34(void __iomem *base)
writel_relaxed(0x0, base + DAVINCI_TIMER_REG_TIM34);
writel_relaxed(UINT_MAX, base + DAVINCI_TIMER_REG_PRD34);
writel_relaxed(tcr, base + DAVINCI_TIMER_REG_TCR);
+
+ davinci_clocksource.initialized = true;
}
/*
--
2.23.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists•infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-12-24 10:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-24 10:03 [PATCH v2 0/3] ARM: davinci: convert dm365 to using the new clocksource driver Bartosz Golaszewski
2019-12-24 10:03 ` Bartosz Golaszewski [this message]
2020-01-09 23:12 ` [PATCH v2 1/3] clocksource: davinci: only enable tim34 in periodic mode once it's initialized Daniel Lezcano
2020-01-10 17:05 ` Bartosz Golaszewski
2019-12-24 10:03 ` [PATCH v2 2/3] ARM: davinci: dm365: switch to using the clocksource driver Bartosz Golaszewski
2019-12-24 10:03 ` [PATCH v2 3/3] ARM: davinci: remove legacy timer support Bartosz Golaszewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191224100328.13608-2-brgl@bgdev.pl \
--to=brgl@bgdev$(echo .)pl \
--cc=bgolaszewski@baylibre$(echo .)com \
--cc=daniel.lezcano@linaro$(echo .)org \
--cc=david@lechnology$(echo .)com \
--cc=khilman@kernel$(echo .)org \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=nsekhar@ti$(echo .)com \
--cc=tglx@linutronix$(echo .)de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox