clocksource: sunxi: make use of CLKSRC_OF
Using CLKSRC_OF allows to remove the SoC specific sunxi_timer.h header, and instead of using a custom init function in the machine definition use the standard clocksource_of_init function. Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
This commit is contained in:
parent
049817319a
commit
ea71d9a600
@ -1,6 +1,7 @@
|
|||||||
config ARCH_SUNXI
|
config ARCH_SUNXI
|
||||||
bool "Allwinner A1X SOCs" if ARCH_MULTI_V7
|
bool "Allwinner A1X SOCs" if ARCH_MULTI_V7
|
||||||
select CLKSRC_MMIO
|
select CLKSRC_MMIO
|
||||||
|
select CLKSRC_OF
|
||||||
select COMMON_CLK
|
select COMMON_CLK
|
||||||
select GENERIC_CLOCKEVENTS
|
select GENERIC_CLOCKEVENTS
|
||||||
select GENERIC_IRQ_CHIP
|
select GENERIC_IRQ_CHIP
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
* warranty of any kind, whether express or implied.
|
* warranty of any kind, whether express or implied.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <linux/clocksource.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
@ -17,8 +18,8 @@
|
|||||||
#include <linux/of_irq.h>
|
#include <linux/of_irq.h>
|
||||||
#include <linux/of_platform.h>
|
#include <linux/of_platform.h>
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/sunxi_timer.h>
|
|
||||||
|
|
||||||
|
#include <linux/clk/sunxi.h>
|
||||||
#include <linux/irqchip/sunxi.h>
|
#include <linux/irqchip/sunxi.h>
|
||||||
|
|
||||||
#include <asm/mach/arch.h>
|
#include <asm/mach/arch.h>
|
||||||
@ -81,6 +82,12 @@ void __init sunxi_map_io(void)
|
|||||||
iotable_init(sunxi_io_desc, ARRAY_SIZE(sunxi_io_desc));
|
iotable_init(sunxi_io_desc, ARRAY_SIZE(sunxi_io_desc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void __init sunxi_timer_init(void)
|
||||||
|
{
|
||||||
|
sunxi_init_clocks();
|
||||||
|
clocksource_of_init();
|
||||||
|
}
|
||||||
|
|
||||||
static void __init sunxi_dt_init(void)
|
static void __init sunxi_dt_init(void)
|
||||||
{
|
{
|
||||||
sunxi_setup_restart();
|
sunxi_setup_restart();
|
||||||
@ -100,6 +107,6 @@ DT_MACHINE_START(SUNXI_DT, "Allwinner A1X (Device Tree)")
|
|||||||
.init_irq = sunxi_init_irq,
|
.init_irq = sunxi_init_irq,
|
||||||
.handle_irq = sunxi_handle_irq,
|
.handle_irq = sunxi_handle_irq,
|
||||||
.restart = sunxi_restart,
|
.restart = sunxi_restart,
|
||||||
.init_time = &sunxi_timer_init,
|
.init_time = sunxi_timer_init,
|
||||||
.dt_compat = sunxi_board_dt_compat,
|
.dt_compat = sunxi_board_dt_compat,
|
||||||
MACHINE_END
|
MACHINE_END
|
||||||
|
@ -22,8 +22,6 @@
|
|||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/of_address.h>
|
#include <linux/of_address.h>
|
||||||
#include <linux/of_irq.h>
|
#include <linux/of_irq.h>
|
||||||
#include <linux/sunxi_timer.h>
|
|
||||||
#include <linux/clk/sunxi.h>
|
|
||||||
|
|
||||||
#define TIMER_IRQ_EN_REG 0x00
|
#define TIMER_IRQ_EN_REG 0x00
|
||||||
#define TIMER_IRQ_EN(val) (1 << val)
|
#define TIMER_IRQ_EN(val) (1 << val)
|
||||||
@ -98,23 +96,13 @@ static struct irqaction sunxi_timer_irq = {
|
|||||||
.dev_id = &sunxi_clockevent,
|
.dev_id = &sunxi_clockevent,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct of_device_id sunxi_timer_dt_ids[] = {
|
static void __init sunxi_timer_init(struct device_node *node)
|
||||||
{ .compatible = "allwinner,sunxi-timer" },
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
void __init sunxi_timer_init(void)
|
|
||||||
{
|
{
|
||||||
struct device_node *node;
|
|
||||||
unsigned long rate = 0;
|
unsigned long rate = 0;
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
int ret, irq;
|
int ret, irq;
|
||||||
u32 val;
|
u32 val;
|
||||||
|
|
||||||
node = of_find_matching_node(NULL, sunxi_timer_dt_ids);
|
|
||||||
if (!node)
|
|
||||||
panic("No sunxi timer node");
|
|
||||||
|
|
||||||
timer_base = of_iomap(node, 0);
|
timer_base = of_iomap(node, 0);
|
||||||
if (!timer_base)
|
if (!timer_base)
|
||||||
panic("Can't map registers");
|
panic("Can't map registers");
|
||||||
@ -123,8 +111,6 @@ void __init sunxi_timer_init(void)
|
|||||||
if (irq <= 0)
|
if (irq <= 0)
|
||||||
panic("Can't parse IRQ");
|
panic("Can't parse IRQ");
|
||||||
|
|
||||||
sunxi_init_clocks();
|
|
||||||
|
|
||||||
clk = of_clk_get(node, 0);
|
clk = of_clk_get(node, 0);
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(clk))
|
||||||
panic("Can't get timer clock");
|
panic("Can't get timer clock");
|
||||||
@ -158,3 +144,5 @@ void __init sunxi_timer_init(void)
|
|||||||
clockevents_config_and_register(&sunxi_clockevent, rate / TIMER_SCAL,
|
clockevents_config_and_register(&sunxi_clockevent, rate / TIMER_SCAL,
|
||||||
0x1, 0xff);
|
0x1, 0xff);
|
||||||
}
|
}
|
||||||
|
CLOCKSOURCE_OF_DECLARE(sunxi, "allwinner,sunxi-timer",
|
||||||
|
sunxi_timer_init);
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012 Maxime Ripard
|
|
||||||
*
|
|
||||||
* Maxime Ripard <maxime.ripard@free-electrons.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __SUNXI_TIMER_H
|
|
||||||
#define __SUNXI_TIMER_H
|
|
||||||
|
|
||||||
#include <asm/mach/time.h>
|
|
||||||
|
|
||||||
void sunxi_timer_init(void);
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Reference in New Issue
Block a user