Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1235365

Trivial clocksource driver

From Mason <slash.tmp@free.fr>
Newsgroups linux.kernel
Subject Trivial clocksource driver
Date 2015-09-29 18:30 +0200
Message-ID <qe5WW-3k4-19@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


Hello everyone,

I am trying to submit a new ARM port, and Arnd pointed out that the
clocksource code could not live in arch/arm/$PLATFORM, but had to
move to drivers/clocksource (and it had to support DT).

Did I understand correctly? Is this the right place to submit code
as provided below?

Regards.


#include <linux/delay.h>	/* register_current_timer_delay	*/
#include <linux/clocksource.h>	/* clocksource_register_hz	*/
#include <linux/sched_clock.h>	/* sched_clock_register		*/
#include <linux/of_address.h>	/* of_iomap			*/
#include <linux/clk.h>		/* of_clk_get, clk_get_rate	*/

static void __iomem *xtal_in_cnt;
static struct delay_timer delay_timer;

static unsigned long read_xtal_counter(void)
{
	return readl_relaxed(xtal_in_cnt);
}

static u64 read_sched_clock(void)
{
	return read_xtal_counter();
}

static cycle_t read_clocksource(struct clocksource *cs)
{
	return read_xtal_counter();
}

static struct clocksource tango_xtal = {
	.name	= "tango-xtal",
	.rating	= 350,
	.read	= read_clocksource,
	.mask	= CLOCKSOURCE_MASK(32),
	.flags	= CLOCK_SOURCE_IS_CONTINUOUS,
};

static void __init tango_clksrc_init(struct device_node *np)
{
	struct clk *clk = of_clk_get(np, 0);
	unsigned int xtal_freq = clk_get_rate(clk);
	xtal_in_cnt = of_iomap(np, 0);

	delay_timer.freq = xtal_freq;
	delay_timer.read_current_timer = read_xtal_counter;
	register_current_timer_delay(&delay_timer);
	sched_clock_register(read_sched_clock, 32, xtal_freq);
	clocksource_register_hz(&tango_xtal, xtal_freq);
}

CLOCKSOURCE_OF_DECLARE(tango, "sigma,xtal_in_cnt", tango_clksrc_init);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Trivial clocksource driver Mason <slash.tmp@free.fr> - 2015-09-29 18:30 +0200
  Re: Trivial clocksource driver Thomas Gleixner <tglx@linutronix.de> - 2015-09-29 20:40 +0200
    Re: Trivial clocksource driver Mason <slash.tmp@free.fr> - 2015-09-29 21:50 +0200
      Re: Trivial clocksource driver Måns Rullgård <mans@mansr.com> - 2015-09-29 22:20 +0200
        Re: Trivial clocksource driver Thomas Gleixner <tglx@linutronix.de> - 2015-09-29 23:00 +0200
        Re: Trivial clocksource driver Mason <slash.tmp@free.fr> - 2015-09-29 23:20 +0200
          Re: Trivial clocksource driver Måns Rullgård <mans@mansr.com> - 2015-09-30 00:00 +0200

csiph-web