From: sboyd@codeaurora.org (Stephen Boyd)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 3/5] ARM: bcm4760: Add system timer
Date: Wed, 14 Aug 2013 17:30:38 -0700 [thread overview]
Message-ID: <20130815003038.GB27999@codeaurora.org> (raw)
In-Reply-To: <20130814221237.695587612@gmail.com>
On 08/15, Domenico Andreoli wrote:
> +
> +static inline void __iomem *to_load(struct bcm4760_timer *timer)
> +{
> + return timer->base + TIMER_LOAD_OFFSET;
> +}
> +
> +static inline void __iomem *to_control(struct bcm4760_timer *timer)
> +{
> + return timer->base + TIMER_CONTROL_OFFSET;
> +}
> +
> +static inline void __iomem *to_intclr(struct bcm4760_timer *timer)
> +{
> + return timer->base + TIMER_INTCLR_OFFSET;
> +}
> +
> +static inline void __iomem *to_ris(struct bcm4760_timer *timer)
> +{
> + return timer->base + TIMER_RIS_OFFSET;
> +}
> +
> +static inline void __iomem *to_mis(struct bcm4760_timer *timer)
> +{
> + return timer->base + TIMER_MIS_OFFSET;
> +}
Style Nit: This is new. Usually people either make a
<my_driver>_{readl,writel}() function that takes the struct and
an offset or they just add the offset directly in their
readl/writel calls. Can you do that? Probably save some lines of
code.
> +static irqreturn_t bcm4760_timer_interrupt(int irq, void *dev_id)
> +{
> + struct bcm4760_timer *timer = dev_id;
> + void (*event_handler)(struct clock_event_device *);
> +
> + /* check the (masked) interrupt status */
> + if (!readl_relaxed(to_mis(timer)))
> + return IRQ_NONE;
> +
> + /* clear the timer interrupt */
> + writel_relaxed(1, to_intclr(timer));
> +
> + event_handler = ACCESS_ONCE(timer->evt.event_handler);
> + if (event_handler)
> + event_handler(&timer->evt);
This is unfortunate. Do you have a pending timer interrupt left
by the bootloader?
> +
> + return IRQ_HANDLED;
> +}
> +
> +static void __init bcm4760_init_time(struct device_node *node)
> +{
> + void __iomem *base;
> + u32 freq = 24000000;
Why have freq in the DT binding at all then?
> + int irq;
> + struct bcm4760_timer *timer;
> +
> + base = of_iomap(node, 0);
> + if (!base)
> + panic("Can't remap timer registers");
> +
> + timer = kzalloc(sizeof(*timer), GFP_KERNEL);
> + if (!timer)
> + panic("Can't allocate timer struct\n");
> +
> + irq = irq_of_parse_and_map(node, 0);
> + if (irq <= 0)
> + panic("Can't parse timer IRQ");
> +
> + timer->base = base;
> + timer->evt.name = node->name;
> + timer->evt.rating = 300;
> + timer->evt.features = CLOCK_EVT_FEAT_ONESHOT;
> + timer->evt.set_mode = bcm4760_timer_set_mode;
> + timer->evt.set_next_event = bcm4760_timer_set_next_event;
> + timer->evt.cpumask = cpumask_of(0);
> + timer->act.name = node->name;
> + timer->act.flags = IRQF_TIMER | IRQF_SHARED;
> + timer->act.dev_id = timer;
> + timer->act.handler = bcm4760_timer_interrupt;
> +
> + if (setup_irq(irq, &timer->act))
> + panic("Can't set up timer IRQ\n");
> +
> + clockevents_config_and_register(&timer->evt, freq, 0xf, 0xffffffff);
If you switch this registration and the setup_irq() call you
shouldn't need the ACCESS_ONCE() and that check in the irq handler.
Please switch the order and or clear the interrupt before
registering the clockevent and remove the checks in the interrupt
handler.
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
next prev parent reply other threads:[~2013-08-15 0:30 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-14 22:10 [PATCH v3 0/5] ARM: Broadcom BCM4760 support Domenico Andreoli
2013-08-14 22:10 ` [PATCH v3 1/5] ARM: remove duplicates in mach-* and plat-* Domenico Andreoli
2013-08-14 22:10 ` [PATCH v3 2/5] ARM: bcm4760: Add platform infrastructure Domenico Andreoli
2013-08-15 13:28 ` Jason Cooper
2013-08-29 23:17 ` Olof Johansson
2013-08-30 7:53 ` Domenico Andreoli
2013-08-30 21:52 ` Christian Daudt
2013-08-30 21:58 ` Olof Johansson
2013-09-10 16:16 ` Domenico Andreoli
2013-09-13 23:16 ` Christian Daudt
2013-08-14 22:10 ` [PATCH v3 3/5] ARM: bcm4760: Add system timer Domenico Andreoli
2013-08-15 0:30 ` Stephen Boyd [this message]
2013-08-15 6:32 ` Domenico Andreoli
2013-08-29 23:20 ` Olof Johansson
2013-08-29 23:21 ` Olof Johansson
2013-08-30 7:54 ` Domenico Andreoli
2013-08-14 22:10 ` [PATCH v3 4/5] ARM: bcm4760: Add ripple counter Domenico Andreoli
2013-08-14 22:10 ` [PATCH v3 5/5] ARM: bcm4760: Add restart hook Domenico Andreoli
2013-08-29 23:36 ` Olof Johansson
2013-08-30 8:01 ` Domenico Andreoli
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=20130815003038.GB27999@codeaurora.org \
--to=sboyd@codeaurora.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.