forked from luck/tmp_suning_uos_patched
Few late patches to enable arch timer for omap5
using device tree. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQIcBAABAgAGBQJQYKzmAAoJEBvUPslcq6Vz3I4P/iF17vddn2Ytnu8mCihW7nP7 mCAXijfFqpAHTTRjXK6VqvRwU1tUClwLCy2Shi+p5ne7tGOzQKVxeoA3eppdelfQ 9rkA6Z8n/OfeAqqmgo0cAABkoa54vX/t9bRAbvW0HAOnCLSb2XEEnh2pArWqCYvw UcuPekS2Ff3nl5aiEZfvndmUjS+NHlBH759SvBdXpWvvIMDdpYKNvOEML4MPklM3 Vc0nPBe7THmVFIUc4Nr3jIUdaDjAAQMRa8Hl+4sbpZzkdBx8dQQFbI9HTeXM9VqM gdGYuuenRs/Vzkgl881wJ1MlTaTVsSXXRMBI05l0DOBCZht16YJZ3OZ9zM8u6Ns4 nrOrzpwG9dBNxZ0OlnmJbyWau3FgWU30FVRTEL3OQtscyOOlbFxNB6NP5uuayNNN 2Zey6R863xjO1d+p13rh1HVu2Lj49YjlvQoaz49YWbVHjR0wR1sNN3dXqZgb6r9u bsqaQMXn6tCBIYSeeA7V4TB39lK0fzMT3w8bbo2Y3ozW0hY9TG8I2hX+/fnc1h5W hQBAlqnLmBoCwlBqLI11XvDWchiVceUgLeJwk712aD7X8IKbBQ1cUhnTem9UKaKS gKYkQTL3GUO7vF0Io9aVX3Q+IngX8xb5YOezK1V4pv5vqeDJ6QqCIjinBeOuKCk6 uDgvIAfF2DwZEfNUpV/R =LDvq -----END PGP SIGNATURE----- Merge tag 'devel-dt-arch-timer-for-v3.7' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap into next/dt From Tony Lindgren: Few late patches to enable arch timer for omap5 using device tree. * tag 'devel-dt-arch-timer-for-v3.7' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap: ARM: OMAP5: Enable arch timer support ARM: OMAP: Add initialisation for the real-time counter.
This commit is contained in:
commit
d5f73cd6e2
|
@ -33,9 +33,21 @@ aliases {
|
|||
cpus {
|
||||
cpu@0 {
|
||||
compatible = "arm,cortex-a15";
|
||||
timer {
|
||||
compatible = "arm,armv7-timer";
|
||||
/* 14th PPI IRQ, active low level-sensitive */
|
||||
interrupts = <1 14 0x308>;
|
||||
clock-frequency = <6144000>;
|
||||
};
|
||||
};
|
||||
cpu@1 {
|
||||
compatible = "arm,cortex-a15";
|
||||
timer {
|
||||
compatible = "arm,armv7-timer";
|
||||
/* 14th PPI IRQ, active low level-sensitive */
|
||||
interrupts = <1 14 0x308>;
|
||||
clock-frequency = <6144000>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -25,6 +25,9 @@ config ARCH_OMAP2PLUS_TYPICAL
|
|||
config SOC_HAS_OMAP2_SDRC
|
||||
bool "OMAP2 SDRAM Controller support"
|
||||
|
||||
config SOC_HAS_REALTIME_COUNTER
|
||||
bool "Real time free running counter"
|
||||
|
||||
config ARCH_OMAP2
|
||||
bool "TI OMAP2"
|
||||
depends on ARCH_OMAP2PLUS
|
||||
|
@ -71,6 +74,8 @@ config SOC_OMAP5
|
|||
select ARM_GIC
|
||||
select HAVE_SMP
|
||||
select ARM_CPU_SUSPEND if PM
|
||||
select SOC_HAS_REALTIME_COUNTER
|
||||
select ARM_ARCH_TIMER
|
||||
|
||||
comment "OMAP Core Type"
|
||||
depends on ARCH_OMAP2
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include <asm/smp_twd.h>
|
||||
#include <asm/sched_clock.h>
|
||||
|
||||
#include <asm/arch_timer.h>
|
||||
#include <plat/omap_hwmod.h>
|
||||
#include <plat/omap_device.h>
|
||||
#include <plat/dmtimer.h>
|
||||
|
@ -72,6 +73,11 @@
|
|||
#define OMAP3_SECURE_TIMER 1
|
||||
#endif
|
||||
|
||||
#define REALTIME_COUNTER_BASE 0x48243200
|
||||
#define INCREMENTER_NUMERATOR_OFFSET 0x10
|
||||
#define INCREMENTER_DENUMERATOR_RELOAD_OFFSET 0x14
|
||||
#define NUMERATOR_DENUMERATOR_MASK 0xfffff000
|
||||
|
||||
/* Clockevent code */
|
||||
|
||||
static struct omap_dm_timer clkev;
|
||||
|
@ -349,6 +355,84 @@ static void __init omap2_clocksource_init(int gptimer_id,
|
|||
omap2_gptimer_clocksource_init(gptimer_id, fck_source);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SOC_HAS_REALTIME_COUNTER
|
||||
/*
|
||||
* The realtime counter also called master counter, is a free-running
|
||||
* counter, which is related to real time. It produces the count used
|
||||
* by the CPU local timer peripherals in the MPU cluster. The timer counts
|
||||
* at a rate of 6.144 MHz. Because the device operates on different clocks
|
||||
* in different power modes, the master counter shifts operation between
|
||||
* clocks, adjusting the increment per clock in hardware accordingly to
|
||||
* maintain a constant count rate.
|
||||
*/
|
||||
static void __init realtime_counter_init(void)
|
||||
{
|
||||
void __iomem *base;
|
||||
static struct clk *sys_clk;
|
||||
unsigned long rate;
|
||||
unsigned int reg, num, den;
|
||||
|
||||
base = ioremap(REALTIME_COUNTER_BASE, SZ_32);
|
||||
if (!base) {
|
||||
pr_err("%s: ioremap failed\n", __func__);
|
||||
return;
|
||||
}
|
||||
sys_clk = clk_get(NULL, "sys_clkin_ck");
|
||||
if (!sys_clk) {
|
||||
pr_err("%s: failed to get system clock handle\n", __func__);
|
||||
iounmap(base);
|
||||
return;
|
||||
}
|
||||
|
||||
rate = clk_get_rate(sys_clk);
|
||||
/* Numerator/denumerator values refer TRM Realtime Counter section */
|
||||
switch (rate) {
|
||||
case 1200000:
|
||||
num = 64;
|
||||
den = 125;
|
||||
break;
|
||||
case 1300000:
|
||||
num = 768;
|
||||
den = 1625;
|
||||
break;
|
||||
case 19200000:
|
||||
num = 8;
|
||||
den = 25;
|
||||
break;
|
||||
case 2600000:
|
||||
num = 384;
|
||||
den = 1625;
|
||||
break;
|
||||
case 2700000:
|
||||
num = 256;
|
||||
den = 1125;
|
||||
break;
|
||||
case 38400000:
|
||||
default:
|
||||
/* Program it for 38.4 MHz */
|
||||
num = 4;
|
||||
den = 25;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Program numerator and denumerator registers */
|
||||
reg = __raw_readl(base + INCREMENTER_NUMERATOR_OFFSET) &
|
||||
NUMERATOR_DENUMERATOR_MASK;
|
||||
reg |= num;
|
||||
__raw_writel(reg, base + INCREMENTER_NUMERATOR_OFFSET);
|
||||
|
||||
reg = __raw_readl(base + INCREMENTER_NUMERATOR_OFFSET) &
|
||||
NUMERATOR_DENUMERATOR_MASK;
|
||||
reg |= den;
|
||||
__raw_writel(reg, base + INCREMENTER_DENUMERATOR_RELOAD_OFFSET);
|
||||
|
||||
iounmap(base);
|
||||
}
|
||||
#else
|
||||
static inline void __init realtime_counter_init(void)
|
||||
{}
|
||||
#endif
|
||||
|
||||
#define OMAP_SYS_TIMER_INIT(name, clkev_nr, clkev_src, \
|
||||
clksrc_nr, clksrc_src) \
|
||||
static void __init omap##name##_timer_init(void) \
|
||||
|
@ -410,7 +494,18 @@ OMAP_SYS_TIMER(4)
|
|||
#endif
|
||||
|
||||
#ifdef CONFIG_SOC_OMAP5
|
||||
OMAP_SYS_TIMER_INIT(5, 1, OMAP4_CLKEV_SOURCE, 2, OMAP4_MPU_SOURCE)
|
||||
static void __init omap5_timer_init(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
omap2_gp_clockevent_init(1, OMAP4_CLKEV_SOURCE);
|
||||
omap2_clocksource_init(2, OMAP4_MPU_SOURCE);
|
||||
realtime_counter_init();
|
||||
|
||||
err = arch_timer_of_register();
|
||||
if (err)
|
||||
pr_err("%s: arch_timer_register failed %d\n", __func__, err);
|
||||
}
|
||||
OMAP_SYS_TIMER(5)
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user