2005-11-10 22:26:51 +08:00
|
|
|
/*
|
2011-03-30 06:54:50 +08:00
|
|
|
* linux/arch/arm/mach-omap2/timer.c
|
2005-11-10 22:26:51 +08:00
|
|
|
*
|
|
|
|
* OMAP2 GP timer support.
|
|
|
|
*
|
OMAP2/3 GPTIMER: allow system tick GPTIMER to be changed in board-*.c files
Add a function omap2_gp_clockevent_set_gptimer() for board-*.c files
to use in .init_irq functions to configure the system tick GPTIMER.
Practical choices at this point are GPTIMER1 or GPTIMER12. Both of
these timers are in the WKUP powerdomain, and so are unaffected by
chip power management. GPTIMER1 can use sys_clk as a source, for
applications where a high-resolution timer is more important than
power management. GPTIMER12 has the special property that it has the
secure 32kHz oscillator as its source clock, which may be less prone
to glitches than the off-chip 32kHz oscillator. But on HS devices, it
may not be available for Linux use.
It appears that most boards are fine with GPTIMER1, but BeagleBoard
should use GPTIMER12 when using a 32KiHz timer source, due to hardware bugs
in revisions B4 and below. Modify board-omap3beagle.c to use GPTIMER12.
This patch originally used a Kbuild config option to select the GPTIMER,
but was changed to allow this to be specified in board-*.c files, per
Tony's request.
Kalle Vallo <kalle.valo@nokia.com> found a bug in an earlier version of
this patch - thanks Kalle.
Tested on Beagle rev B4 ES2.1, with and without CONFIG_OMAP_32K_TIMER, and
3430SDP.
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Cc: Kalle Valo <kalle.valo@nokia.com>
2009-04-24 11:11:10 +08:00
|
|
|
* Copyright (C) 2009 Nokia Corporation
|
|
|
|
*
|
2007-11-13 15:24:02 +08:00
|
|
|
* Update to use new clocksource/clockevent layers
|
|
|
|
* Author: Kevin Hilman, MontaVista Software, Inc. <source@mvista.com>
|
|
|
|
* Copyright (C) 2007 MontaVista Software, Inc.
|
|
|
|
*
|
|
|
|
* Original driver:
|
2005-11-10 22:26:51 +08:00
|
|
|
* Copyright (C) 2005 Nokia Corporation
|
|
|
|
* Author: Paul Mundt <paul.mundt@nokia.com>
|
2007-10-20 05:21:04 +08:00
|
|
|
* Juha Yrjölä <juha.yrjola@nokia.com>
|
2006-06-27 07:16:12 +08:00
|
|
|
* OMAP Dual-mode timer framework support by Timo Teras
|
2005-11-10 22:26:51 +08:00
|
|
|
*
|
|
|
|
* Some parts based off of TI's 24xx code:
|
|
|
|
*
|
2009-05-29 05:16:04 +08:00
|
|
|
* Copyright (C) 2004-2009 Texas Instruments, Inc.
|
2005-11-10 22:26:51 +08:00
|
|
|
*
|
|
|
|
* Roughly modelled after the OMAP1 MPU timer code.
|
2009-05-29 05:16:04 +08:00
|
|
|
* Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
|
2005-11-10 22:26:51 +08:00
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/time.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/err.h>
|
2006-01-08 00:15:52 +08:00
|
|
|
#include <linux/clk.h>
|
2006-06-27 07:16:12 +08:00
|
|
|
#include <linux/delay.h>
|
2006-12-07 09:14:00 +08:00
|
|
|
#include <linux/irq.h>
|
2007-11-13 15:24:02 +08:00
|
|
|
#include <linux/clocksource.h>
|
|
|
|
#include <linux/clockchips.h>
|
2011-09-20 19:30:18 +08:00
|
|
|
#include <linux/slab.h>
|
2012-07-04 21:02:32 +08:00
|
|
|
#include <linux/of.h>
|
ARM: OMAP: Add DT support for timer driver
In order to add device-tree support to the timer driver the following changes
were made ...
1. Allocate system timers (used for clock-events and clock-source) based upon
timer properties rather than using an hard-coded timer instance ID. To allow
this a new helper function called omap_dmtimer_find_by_property() has been
added for finding a timer with the particular properties in the device-tree
blob. Please note that this is an internal helper function for system timers
only to find a timer in the device-tree blob. This cannot be used by device
drivers, another API has been added for that (see below). Timers that are
allocated for system timers are dynamically disabled at boot time by adding
a status property with the value "disabled" to the timer's device-tree node.
Please note that when allocating system timers we now pass a timer ID and
timer property. The timer ID is only be used for allocating a timer when
booting without device-tree. Once device-tree migration is complete, all
the timer ID references will be removed.
2. System timer resources (memory and interrupts) are directly obtained from
the device-tree timer node when booting with device-tree, so that system
timers are no longer reliant upon the OMAP HWMOD framework to provide these
resources.
3. If DT blob is present, then let device-tree create the timer devices
dynamically.
4. When device-tree is present the "id" field in the platform_device structure
(pdev->id) is initialised to -1 and hence cannot be used to identify a timer
instance. Due to this the following changes were made ...
a). The API omap_dm_timer_request_specific() is not supported when using
device-tree, because it uses the device ID to request a specific timer.
This function will return an error if called when device-tree is present.
Users of this API should use omap_dm_timer_request_by_cap() instead.
b). When removing the DMTIMER driver, the timer "id" was used to identify the
timer instance. The remove function has been modified to use the device
name instead of the "id".
5. When device-tree is present the platform_data structure will be NULL and so
check for this.
6. The OMAP timer device tree binding has the following optional parameters ...
a). ti,timer-alwon --> Timer is in an always-on power domain
b). ti,timer-dsp --> Timer can generate an interrupt to the on-chip DSP
c). ti,timer-pwm --> Timer can generate a PWM output
d). ti,timer-secure --> Timer is reserved on a secure OMAP device
Search for the above parameters and set the appropriate timer attribute
flags.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
2012-05-14 23:41:37 +08:00
|
|
|
#include <linux/of_address.h>
|
|
|
|
#include <linux/of_irq.h>
|
2012-09-29 00:34:49 +08:00
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/platform_data/dmtimer-omap.h>
|
2013-06-02 14:39:40 +08:00
|
|
|
#include <linux/sched_clock.h>
|
2024-06-12 13:13:20 +08:00
|
|
|
#include <linux/cpu.h>
|
2006-01-08 00:15:52 +08:00
|
|
|
|
2005-11-10 22:26:51 +08:00
|
|
|
#include <asm/mach/time.h>
|
2012-08-28 08:43:01 +08:00
|
|
|
|
2012-10-03 08:41:35 +08:00
|
|
|
#include "omap_hwmod.h"
|
2012-10-03 08:25:48 +08:00
|
|
|
#include "omap_device.h"
|
2012-10-30 07:45:47 +08:00
|
|
|
#include <plat/counter-32k.h>
|
2018-02-15 14:01:44 +08:00
|
|
|
#include <clocksource/timer-ti-dm.h>
|
2011-09-20 19:30:24 +08:00
|
|
|
|
2012-09-01 01:59:07 +08:00
|
|
|
#include "soc.h"
|
2012-08-28 08:43:01 +08:00
|
|
|
#include "common.h"
|
2015-01-06 07:45:45 +08:00
|
|
|
#include "control.h"
|
2011-09-20 19:30:24 +08:00
|
|
|
#include "powerdomain.h"
|
2013-10-10 15:43:48 +08:00
|
|
|
#include "omap-secure.h"
|
2005-11-10 22:26:51 +08:00
|
|
|
|
2012-08-13 16:54:24 +08:00
|
|
|
#define REALTIME_COUNTER_BASE 0x48243200
|
|
|
|
#define INCREMENTER_NUMERATOR_OFFSET 0x10
|
|
|
|
#define INCREMENTER_DENUMERATOR_RELOAD_OFFSET 0x14
|
|
|
|
#define NUMERATOR_DENUMERATOR_MASK 0xfffff000
|
|
|
|
|
2011-03-30 06:54:48 +08:00
|
|
|
/* Clockevent code */
|
|
|
|
|
2017-03-29 09:57:55 +08:00
|
|
|
/* Clockevent hwmod for am335x and am437x suspend */
|
|
|
|
static struct omap_hwmod *clockevent_gpt_hwmod;
|
|
|
|
|
2018-05-23 02:22:20 +08:00
|
|
|
/* Clockesource hwmod for am437x suspend */
|
|
|
|
static struct omap_hwmod *clocksource_gpt_hwmod;
|
|
|
|
|
2024-06-12 13:13:20 +08:00
|
|
|
struct dmtimer_clockevent {
|
|
|
|
struct clock_event_device dev;
|
|
|
|
struct omap_dm_timer timer;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct dmtimer_clockevent clockevent;
|
|
|
|
|
|
|
|
static struct omap_dm_timer *to_dmtimer(struct clock_event_device *clockevent)
|
|
|
|
{
|
|
|
|
struct dmtimer_clockevent *clkevt =
|
|
|
|
container_of(clockevent, struct dmtimer_clockevent, dev);
|
|
|
|
struct omap_dm_timer *timer = &clkevt->timer;
|
|
|
|
|
|
|
|
return timer;
|
|
|
|
}
|
|
|
|
|
2013-10-12 08:28:04 +08:00
|
|
|
#ifdef CONFIG_SOC_HAS_REALTIME_COUNTER
|
2013-10-10 15:43:48 +08:00
|
|
|
static unsigned long arch_timer_freq;
|
|
|
|
|
|
|
|
void set_cntfreq(void)
|
|
|
|
{
|
|
|
|
omap_smc1(OMAP5_DRA7_MON_SET_CNTFRQ_INDEX, arch_timer_freq);
|
|
|
|
}
|
2013-10-12 08:28:04 +08:00
|
|
|
#endif
|
2005-11-10 22:26:51 +08:00
|
|
|
|
2006-10-07 01:53:39 +08:00
|
|
|
static irqreturn_t omap2_gp_timer_interrupt(int irq, void *dev_id)
|
2005-11-10 22:26:51 +08:00
|
|
|
{
|
2024-06-12 13:13:20 +08:00
|
|
|
struct dmtimer_clockevent *clkevt = dev_id;
|
|
|
|
struct clock_event_device *evt = &clkevt->dev;
|
|
|
|
struct omap_dm_timer *timer = &clkevt->timer;
|
2005-11-10 22:26:51 +08:00
|
|
|
|
2024-06-12 13:13:20 +08:00
|
|
|
__omap_dm_timer_write_status(timer, OMAP_TIMER_INT_OVERFLOW);
|
2007-11-13 15:24:02 +08:00
|
|
|
evt->event_handler(evt);
|
2005-11-10 22:26:51 +08:00
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
2007-11-13 15:24:02 +08:00
|
|
|
static int omap2_gp_timer_set_next_event(unsigned long cycles,
|
|
|
|
struct clock_event_device *evt)
|
2005-11-10 22:26:51 +08:00
|
|
|
{
|
2024-06-12 13:13:20 +08:00
|
|
|
struct omap_dm_timer *timer = to_dmtimer(evt);
|
|
|
|
|
|
|
|
__omap_dm_timer_load_start(timer, OMAP_TIMER_CTRL_ST,
|
2012-09-28 00:49:45 +08:00
|
|
|
0xffffffff - cycles, OMAP_TIMER_POSTED);
|
2007-11-13 15:24:02 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-02-27 16:09:52 +08:00
|
|
|
static int omap2_gp_timer_shutdown(struct clock_event_device *evt)
|
|
|
|
{
|
2024-06-12 13:13:20 +08:00
|
|
|
struct omap_dm_timer *timer = to_dmtimer(evt);
|
|
|
|
|
|
|
|
__omap_dm_timer_stop(timer, OMAP_TIMER_POSTED, timer->rate);
|
|
|
|
|
2015-02-27 16:09:52 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int omap2_gp_timer_set_periodic(struct clock_event_device *evt)
|
2007-11-13 15:24:02 +08:00
|
|
|
{
|
2024-06-12 13:13:20 +08:00
|
|
|
struct omap_dm_timer *timer = to_dmtimer(evt);
|
2007-11-13 15:24:02 +08:00
|
|
|
u32 period;
|
|
|
|
|
2024-06-12 13:13:20 +08:00
|
|
|
__omap_dm_timer_stop(timer, OMAP_TIMER_POSTED, timer->rate);
|
2007-11-13 15:24:02 +08:00
|
|
|
|
2024-06-12 13:13:20 +08:00
|
|
|
period = timer->rate / HZ;
|
2015-02-27 16:09:52 +08:00
|
|
|
period -= 1;
|
|
|
|
/* Looks like we need to first set the load value separately */
|
2024-06-12 13:13:20 +08:00
|
|
|
__omap_dm_timer_write(timer, OMAP_TIMER_LOAD_REG, 0xffffffff - period,
|
2015-02-27 16:09:52 +08:00
|
|
|
OMAP_TIMER_POSTED);
|
2024-06-12 13:13:20 +08:00
|
|
|
__omap_dm_timer_load_start(timer,
|
2015-02-27 16:09:52 +08:00
|
|
|
OMAP_TIMER_CTRL_AR | OMAP_TIMER_CTRL_ST,
|
|
|
|
0xffffffff - period, OMAP_TIMER_POSTED);
|
|
|
|
return 0;
|
2007-11-13 15:24:02 +08:00
|
|
|
}
|
|
|
|
|
2017-03-29 09:57:55 +08:00
|
|
|
static void omap_clkevt_idle(struct clock_event_device *unused)
|
|
|
|
{
|
|
|
|
if (!clockevent_gpt_hwmod)
|
|
|
|
return;
|
|
|
|
|
|
|
|
omap_hwmod_idle(clockevent_gpt_hwmod);
|
|
|
|
}
|
|
|
|
|
2024-06-12 13:13:20 +08:00
|
|
|
static void omap_clkevt_unidle(struct clock_event_device *evt)
|
2017-03-29 09:57:55 +08:00
|
|
|
{
|
2024-06-12 13:13:20 +08:00
|
|
|
struct omap_dm_timer *timer = to_dmtimer(evt);
|
|
|
|
|
2017-03-29 09:57:55 +08:00
|
|
|
if (!clockevent_gpt_hwmod)
|
|
|
|
return;
|
|
|
|
|
|
|
|
omap_hwmod_enable(clockevent_gpt_hwmod);
|
2024-06-12 13:13:20 +08:00
|
|
|
__omap_dm_timer_int_enable(timer, OMAP_TIMER_INT_OVERFLOW);
|
2017-03-29 09:57:55 +08:00
|
|
|
}
|
|
|
|
|
2014-09-10 16:26:17 +08:00
|
|
|
static const struct of_device_id omap_timer_match[] __initconst = {
|
2013-03-20 01:38:18 +08:00
|
|
|
{ .compatible = "ti,omap2420-timer", },
|
|
|
|
{ .compatible = "ti,omap3430-timer", },
|
|
|
|
{ .compatible = "ti,omap4430-timer", },
|
|
|
|
{ .compatible = "ti,omap5430-timer", },
|
2015-01-15 09:37:16 +08:00
|
|
|
{ .compatible = "ti,dm814-timer", },
|
|
|
|
{ .compatible = "ti,dm816-timer", },
|
2013-03-20 01:38:18 +08:00
|
|
|
{ .compatible = "ti,am335x-timer", },
|
|
|
|
{ .compatible = "ti,am335x-timer-1ms", },
|
2012-06-21 04:55:24 +08:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2018-04-17 01:21:39 +08:00
|
|
|
static int omap_timer_add_disabled_property(struct device_node *np)
|
|
|
|
{
|
|
|
|
struct property *prop;
|
|
|
|
|
|
|
|
prop = kzalloc(sizeof(*prop), GFP_KERNEL);
|
|
|
|
if (!prop)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
prop->name = "status";
|
|
|
|
prop->value = "disabled";
|
|
|
|
prop->length = strlen(prop->value);
|
|
|
|
|
|
|
|
return of_add_property(np, prop);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int omap_timer_update_dt(struct device_node *np)
|
|
|
|
{
|
|
|
|
int error = 0;
|
|
|
|
|
|
|
|
if (!of_device_is_compatible(np, "ti,omap-counter32k")) {
|
|
|
|
error = omap_timer_add_disabled_property(np);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* No parent interconnect target module configured? */
|
|
|
|
if (of_get_property(np, "ti,hwmods", NULL))
|
|
|
|
return error;
|
|
|
|
|
|
|
|
/* Tag parent interconnect target module disabled */
|
|
|
|
error = omap_timer_add_disabled_property(np->parent);
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
ARM: OMAP: Add DT support for timer driver
In order to add device-tree support to the timer driver the following changes
were made ...
1. Allocate system timers (used for clock-events and clock-source) based upon
timer properties rather than using an hard-coded timer instance ID. To allow
this a new helper function called omap_dmtimer_find_by_property() has been
added for finding a timer with the particular properties in the device-tree
blob. Please note that this is an internal helper function for system timers
only to find a timer in the device-tree blob. This cannot be used by device
drivers, another API has been added for that (see below). Timers that are
allocated for system timers are dynamically disabled at boot time by adding
a status property with the value "disabled" to the timer's device-tree node.
Please note that when allocating system timers we now pass a timer ID and
timer property. The timer ID is only be used for allocating a timer when
booting without device-tree. Once device-tree migration is complete, all
the timer ID references will be removed.
2. System timer resources (memory and interrupts) are directly obtained from
the device-tree timer node when booting with device-tree, so that system
timers are no longer reliant upon the OMAP HWMOD framework to provide these
resources.
3. If DT blob is present, then let device-tree create the timer devices
dynamically.
4. When device-tree is present the "id" field in the platform_device structure
(pdev->id) is initialised to -1 and hence cannot be used to identify a timer
instance. Due to this the following changes were made ...
a). The API omap_dm_timer_request_specific() is not supported when using
device-tree, because it uses the device ID to request a specific timer.
This function will return an error if called when device-tree is present.
Users of this API should use omap_dm_timer_request_by_cap() instead.
b). When removing the DMTIMER driver, the timer "id" was used to identify the
timer instance. The remove function has been modified to use the device
name instead of the "id".
5. When device-tree is present the platform_data structure will be NULL and so
check for this.
6. The OMAP timer device tree binding has the following optional parameters ...
a). ti,timer-alwon --> Timer is in an always-on power domain
b). ti,timer-dsp --> Timer can generate an interrupt to the on-chip DSP
c). ti,timer-pwm --> Timer can generate a PWM output
d). ti,timer-secure --> Timer is reserved on a secure OMAP device
Search for the above parameters and set the appropriate timer attribute
flags.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
2012-05-14 23:41:37 +08:00
|
|
|
/**
|
|
|
|
* omap_get_timer_dt - get a timer using device-tree
|
|
|
|
* @match - device-tree match structure for matching a device type
|
|
|
|
* @property - optional timer property to match
|
|
|
|
*
|
|
|
|
* Helper function to get a timer during early boot using device-tree for use
|
|
|
|
* as kernel system timer. Optionally, the property argument can be used to
|
|
|
|
* select a timer with a specific property. Once a timer is found then mark
|
|
|
|
* the timer node in device-tree as disabled, to prevent the kernel from
|
|
|
|
* registering this timer as a platform device and so no one else can use it.
|
|
|
|
*/
|
2014-09-10 16:26:17 +08:00
|
|
|
static struct device_node * __init omap_get_timer_dt(const struct of_device_id *match,
|
ARM: OMAP: Add DT support for timer driver
In order to add device-tree support to the timer driver the following changes
were made ...
1. Allocate system timers (used for clock-events and clock-source) based upon
timer properties rather than using an hard-coded timer instance ID. To allow
this a new helper function called omap_dmtimer_find_by_property() has been
added for finding a timer with the particular properties in the device-tree
blob. Please note that this is an internal helper function for system timers
only to find a timer in the device-tree blob. This cannot be used by device
drivers, another API has been added for that (see below). Timers that are
allocated for system timers are dynamically disabled at boot time by adding
a status property with the value "disabled" to the timer's device-tree node.
Please note that when allocating system timers we now pass a timer ID and
timer property. The timer ID is only be used for allocating a timer when
booting without device-tree. Once device-tree migration is complete, all
the timer ID references will be removed.
2. System timer resources (memory and interrupts) are directly obtained from
the device-tree timer node when booting with device-tree, so that system
timers are no longer reliant upon the OMAP HWMOD framework to provide these
resources.
3. If DT blob is present, then let device-tree create the timer devices
dynamically.
4. When device-tree is present the "id" field in the platform_device structure
(pdev->id) is initialised to -1 and hence cannot be used to identify a timer
instance. Due to this the following changes were made ...
a). The API omap_dm_timer_request_specific() is not supported when using
device-tree, because it uses the device ID to request a specific timer.
This function will return an error if called when device-tree is present.
Users of this API should use omap_dm_timer_request_by_cap() instead.
b). When removing the DMTIMER driver, the timer "id" was used to identify the
timer instance. The remove function has been modified to use the device
name instead of the "id".
5. When device-tree is present the platform_data structure will be NULL and so
check for this.
6. The OMAP timer device tree binding has the following optional parameters ...
a). ti,timer-alwon --> Timer is in an always-on power domain
b). ti,timer-dsp --> Timer can generate an interrupt to the on-chip DSP
c). ti,timer-pwm --> Timer can generate a PWM output
d). ti,timer-secure --> Timer is reserved on a secure OMAP device
Search for the above parameters and set the appropriate timer attribute
flags.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
2012-05-14 23:41:37 +08:00
|
|
|
const char *property)
|
|
|
|
{
|
|
|
|
struct device_node *np;
|
2018-04-17 01:21:39 +08:00
|
|
|
int error;
|
ARM: OMAP: Add DT support for timer driver
In order to add device-tree support to the timer driver the following changes
were made ...
1. Allocate system timers (used for clock-events and clock-source) based upon
timer properties rather than using an hard-coded timer instance ID. To allow
this a new helper function called omap_dmtimer_find_by_property() has been
added for finding a timer with the particular properties in the device-tree
blob. Please note that this is an internal helper function for system timers
only to find a timer in the device-tree blob. This cannot be used by device
drivers, another API has been added for that (see below). Timers that are
allocated for system timers are dynamically disabled at boot time by adding
a status property with the value "disabled" to the timer's device-tree node.
Please note that when allocating system timers we now pass a timer ID and
timer property. The timer ID is only be used for allocating a timer when
booting without device-tree. Once device-tree migration is complete, all
the timer ID references will be removed.
2. System timer resources (memory and interrupts) are directly obtained from
the device-tree timer node when booting with device-tree, so that system
timers are no longer reliant upon the OMAP HWMOD framework to provide these
resources.
3. If DT blob is present, then let device-tree create the timer devices
dynamically.
4. When device-tree is present the "id" field in the platform_device structure
(pdev->id) is initialised to -1 and hence cannot be used to identify a timer
instance. Due to this the following changes were made ...
a). The API omap_dm_timer_request_specific() is not supported when using
device-tree, because it uses the device ID to request a specific timer.
This function will return an error if called when device-tree is present.
Users of this API should use omap_dm_timer_request_by_cap() instead.
b). When removing the DMTIMER driver, the timer "id" was used to identify the
timer instance. The remove function has been modified to use the device
name instead of the "id".
5. When device-tree is present the platform_data structure will be NULL and so
check for this.
6. The OMAP timer device tree binding has the following optional parameters ...
a). ti,timer-alwon --> Timer is in an always-on power domain
b). ti,timer-dsp --> Timer can generate an interrupt to the on-chip DSP
c). ti,timer-pwm --> Timer can generate a PWM output
d). ti,timer-secure --> Timer is reserved on a secure OMAP device
Search for the above parameters and set the appropriate timer attribute
flags.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
2012-05-14 23:41:37 +08:00
|
|
|
|
|
|
|
for_each_matching_node(np, match) {
|
2013-01-08 21:31:42 +08:00
|
|
|
if (!of_device_is_available(np))
|
ARM: OMAP: Add DT support for timer driver
In order to add device-tree support to the timer driver the following changes
were made ...
1. Allocate system timers (used for clock-events and clock-source) based upon
timer properties rather than using an hard-coded timer instance ID. To allow
this a new helper function called omap_dmtimer_find_by_property() has been
added for finding a timer with the particular properties in the device-tree
blob. Please note that this is an internal helper function for system timers
only to find a timer in the device-tree blob. This cannot be used by device
drivers, another API has been added for that (see below). Timers that are
allocated for system timers are dynamically disabled at boot time by adding
a status property with the value "disabled" to the timer's device-tree node.
Please note that when allocating system timers we now pass a timer ID and
timer property. The timer ID is only be used for allocating a timer when
booting without device-tree. Once device-tree migration is complete, all
the timer ID references will be removed.
2. System timer resources (memory and interrupts) are directly obtained from
the device-tree timer node when booting with device-tree, so that system
timers are no longer reliant upon the OMAP HWMOD framework to provide these
resources.
3. If DT blob is present, then let device-tree create the timer devices
dynamically.
4. When device-tree is present the "id" field in the platform_device structure
(pdev->id) is initialised to -1 and hence cannot be used to identify a timer
instance. Due to this the following changes were made ...
a). The API omap_dm_timer_request_specific() is not supported when using
device-tree, because it uses the device ID to request a specific timer.
This function will return an error if called when device-tree is present.
Users of this API should use omap_dm_timer_request_by_cap() instead.
b). When removing the DMTIMER driver, the timer "id" was used to identify the
timer instance. The remove function has been modified to use the device
name instead of the "id".
5. When device-tree is present the platform_data structure will be NULL and so
check for this.
6. The OMAP timer device tree binding has the following optional parameters ...
a). ti,timer-alwon --> Timer is in an always-on power domain
b). ti,timer-dsp --> Timer can generate an interrupt to the on-chip DSP
c). ti,timer-pwm --> Timer can generate a PWM output
d). ti,timer-secure --> Timer is reserved on a secure OMAP device
Search for the above parameters and set the appropriate timer attribute
flags.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
2012-05-14 23:41:37 +08:00
|
|
|
continue;
|
|
|
|
|
2013-01-08 21:31:42 +08:00
|
|
|
if (property && !of_get_property(np, property, NULL))
|
ARM: OMAP: Add DT support for timer driver
In order to add device-tree support to the timer driver the following changes
were made ...
1. Allocate system timers (used for clock-events and clock-source) based upon
timer properties rather than using an hard-coded timer instance ID. To allow
this a new helper function called omap_dmtimer_find_by_property() has been
added for finding a timer with the particular properties in the device-tree
blob. Please note that this is an internal helper function for system timers
only to find a timer in the device-tree blob. This cannot be used by device
drivers, another API has been added for that (see below). Timers that are
allocated for system timers are dynamically disabled at boot time by adding
a status property with the value "disabled" to the timer's device-tree node.
Please note that when allocating system timers we now pass a timer ID and
timer property. The timer ID is only be used for allocating a timer when
booting without device-tree. Once device-tree migration is complete, all
the timer ID references will be removed.
2. System timer resources (memory and interrupts) are directly obtained from
the device-tree timer node when booting with device-tree, so that system
timers are no longer reliant upon the OMAP HWMOD framework to provide these
resources.
3. If DT blob is present, then let device-tree create the timer devices
dynamically.
4. When device-tree is present the "id" field in the platform_device structure
(pdev->id) is initialised to -1 and hence cannot be used to identify a timer
instance. Due to this the following changes were made ...
a). The API omap_dm_timer_request_specific() is not supported when using
device-tree, because it uses the device ID to request a specific timer.
This function will return an error if called when device-tree is present.
Users of this API should use omap_dm_timer_request_by_cap() instead.
b). When removing the DMTIMER driver, the timer "id" was used to identify the
timer instance. The remove function has been modified to use the device
name instead of the "id".
5. When device-tree is present the platform_data structure will be NULL and so
check for this.
6. The OMAP timer device tree binding has the following optional parameters ...
a). ti,timer-alwon --> Timer is in an always-on power domain
b). ti,timer-dsp --> Timer can generate an interrupt to the on-chip DSP
c). ti,timer-pwm --> Timer can generate a PWM output
d). ti,timer-secure --> Timer is reserved on a secure OMAP device
Search for the above parameters and set the appropriate timer attribute
flags.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
2012-05-14 23:41:37 +08:00
|
|
|
continue;
|
|
|
|
|
ARM: OMAP3: Update clocksource timer selection
When booting with device-tree for OMAP3 and AM335x devices and a gptimer
is used as the clocksource (which is always the case for AM335x), a
gptimer located in a power domain that is not always-on is selected.
Ideally we should use a gptimer for clocksource that is located in a
power domain that is always on (such as the wake-up domain) so that time
can be maintained during a kernel suspend without keeping on additional
power domains unnecessarily.
In order to fix this so that we can select a gptimer located in a power
domain that is always-on, the following changes were made ...
1. Currently, only when selecting a gptimer to use for a clockevent
timer, do we pass a timer property that can be used to select a
specific gptimer. Change this so that we can pass a property when
selecting a gptimer to use for a clocksource timer too.
2. Currently, when selecting either a gptimer to use for a clockevent
timer or a clocksource timer and no timer property is passed, then
the first available timer is selected regardless of the properties
it has. Change this so that if no properties are passed, then a timer
that does not have additional features (such as always-on, dsp-irq,
pwm, and secure) is selected.
For OMAP3 and AM335x devices that use a gptimer for clocksource, change
the selection of the gptimer so that by default the gptimer located in
the always-on power domain is used for clocksource instead of
clockevents.
Please note that using a gptimer for both clocksource and clockevents
can have a system power impact during idle. The reason being is that
OMAP and AMxxx devices typically only have one gptimer in a power domain
that is always-on. Therefore when the kernel is idle both the clocksource
and clockevent timers will be active and this will keep additional power
domains on. During kernel suspend, only the clocksource timer is active
and therefore, it is better to use a gptimer in a power domain that is
always-on for clocksource.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Acked-by: Igor Grinberg <grinberg@compulab.co.il>
2013-01-29 07:53:57 +08:00
|
|
|
if (!property && (of_get_property(np, "ti,timer-alwon", NULL) ||
|
|
|
|
of_get_property(np, "ti,timer-dsp", NULL) ||
|
|
|
|
of_get_property(np, "ti,timer-pwm", NULL) ||
|
|
|
|
of_get_property(np, "ti,timer-secure", NULL)))
|
|
|
|
continue;
|
|
|
|
|
2018-04-17 01:21:39 +08:00
|
|
|
error = omap_timer_update_dt(np);
|
|
|
|
WARN(error, "%s: Could not update dt: %i\n", __func__, error);
|
|
|
|
|
ARM: OMAP: Add DT support for timer driver
In order to add device-tree support to the timer driver the following changes
were made ...
1. Allocate system timers (used for clock-events and clock-source) based upon
timer properties rather than using an hard-coded timer instance ID. To allow
this a new helper function called omap_dmtimer_find_by_property() has been
added for finding a timer with the particular properties in the device-tree
blob. Please note that this is an internal helper function for system timers
only to find a timer in the device-tree blob. This cannot be used by device
drivers, another API has been added for that (see below). Timers that are
allocated for system timers are dynamically disabled at boot time by adding
a status property with the value "disabled" to the timer's device-tree node.
Please note that when allocating system timers we now pass a timer ID and
timer property. The timer ID is only be used for allocating a timer when
booting without device-tree. Once device-tree migration is complete, all
the timer ID references will be removed.
2. System timer resources (memory and interrupts) are directly obtained from
the device-tree timer node when booting with device-tree, so that system
timers are no longer reliant upon the OMAP HWMOD framework to provide these
resources.
3. If DT blob is present, then let device-tree create the timer devices
dynamically.
4. When device-tree is present the "id" field in the platform_device structure
(pdev->id) is initialised to -1 and hence cannot be used to identify a timer
instance. Due to this the following changes were made ...
a). The API omap_dm_timer_request_specific() is not supported when using
device-tree, because it uses the device ID to request a specific timer.
This function will return an error if called when device-tree is present.
Users of this API should use omap_dm_timer_request_by_cap() instead.
b). When removing the DMTIMER driver, the timer "id" was used to identify the
timer instance. The remove function has been modified to use the device
name instead of the "id".
5. When device-tree is present the platform_data structure will be NULL and so
check for this.
6. The OMAP timer device tree binding has the following optional parameters ...
a). ti,timer-alwon --> Timer is in an always-on power domain
b). ti,timer-dsp --> Timer can generate an interrupt to the on-chip DSP
c). ti,timer-pwm --> Timer can generate a PWM output
d). ti,timer-secure --> Timer is reserved on a secure OMAP device
Search for the above parameters and set the appropriate timer attribute
flags.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
2012-05-14 23:41:37 +08:00
|
|
|
return np;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-06-21 04:55:24 +08:00
|
|
|
/**
|
|
|
|
* omap_dmtimer_init - initialisation function when device tree is used
|
|
|
|
*
|
2015-10-06 07:28:22 +08:00
|
|
|
* For secure OMAP3/DRA7xx devices, timers with device type "timer-secure"
|
|
|
|
* cannot be used by the kernel as they are reserved. Therefore, to prevent the
|
2012-06-21 04:55:24 +08:00
|
|
|
* kernel registering these devices remove them dynamically from the device
|
|
|
|
* tree on boot.
|
|
|
|
*/
|
2012-11-29 05:56:41 +08:00
|
|
|
static void __init omap_dmtimer_init(void)
|
2012-06-21 04:55:24 +08:00
|
|
|
{
|
|
|
|
struct device_node *np;
|
|
|
|
|
2015-10-06 07:28:22 +08:00
|
|
|
if (!cpu_is_omap34xx() && !soc_is_dra7xx())
|
2012-06-21 04:55:24 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* If we are a secure device, remove any secure timer nodes */
|
|
|
|
if ((omap_type() != OMAP2_DEVICE_TYPE_GP)) {
|
ARM: OMAP: Add DT support for timer driver
In order to add device-tree support to the timer driver the following changes
were made ...
1. Allocate system timers (used for clock-events and clock-source) based upon
timer properties rather than using an hard-coded timer instance ID. To allow
this a new helper function called omap_dmtimer_find_by_property() has been
added for finding a timer with the particular properties in the device-tree
blob. Please note that this is an internal helper function for system timers
only to find a timer in the device-tree blob. This cannot be used by device
drivers, another API has been added for that (see below). Timers that are
allocated for system timers are dynamically disabled at boot time by adding
a status property with the value "disabled" to the timer's device-tree node.
Please note that when allocating system timers we now pass a timer ID and
timer property. The timer ID is only be used for allocating a timer when
booting without device-tree. Once device-tree migration is complete, all
the timer ID references will be removed.
2. System timer resources (memory and interrupts) are directly obtained from
the device-tree timer node when booting with device-tree, so that system
timers are no longer reliant upon the OMAP HWMOD framework to provide these
resources.
3. If DT blob is present, then let device-tree create the timer devices
dynamically.
4. When device-tree is present the "id" field in the platform_device structure
(pdev->id) is initialised to -1 and hence cannot be used to identify a timer
instance. Due to this the following changes were made ...
a). The API omap_dm_timer_request_specific() is not supported when using
device-tree, because it uses the device ID to request a specific timer.
This function will return an error if called when device-tree is present.
Users of this API should use omap_dm_timer_request_by_cap() instead.
b). When removing the DMTIMER driver, the timer "id" was used to identify the
timer instance. The remove function has been modified to use the device
name instead of the "id".
5. When device-tree is present the platform_data structure will be NULL and so
check for this.
6. The OMAP timer device tree binding has the following optional parameters ...
a). ti,timer-alwon --> Timer is in an always-on power domain
b). ti,timer-dsp --> Timer can generate an interrupt to the on-chip DSP
c). ti,timer-pwm --> Timer can generate a PWM output
d). ti,timer-secure --> Timer is reserved on a secure OMAP device
Search for the above parameters and set the appropriate timer attribute
flags.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
2012-05-14 23:41:37 +08:00
|
|
|
np = omap_get_timer_dt(omap_timer_match, "ti,timer-secure");
|
2015-06-30 20:00:16 +08:00
|
|
|
of_node_put(np);
|
2012-06-21 04:55:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
ARM: OMAP3+: Implement timer workaround for errata i103 and i767
Errata Titles:
i103: Delay needed to read some GP timer, WD timer and sync timer
registers after wakeup (OMAP3/4)
i767: Delay needed to read some GP timer registers after wakeup (OMAP5)
Description (i103/i767):
If a General Purpose Timer (GPTimer) is in posted mode
(TSICR [2].POSTED=1), due to internal resynchronizations, values read in
TCRR, TCAR1 and TCAR2 registers right after the timer interface clock
(L4) goes from stopped to active may not return the expected values. The
most common event leading to this situation occurs upon wake up from
idle.
GPTimer non-posted synchronization mode is not impacted by this
limitation.
Workarounds:
1). Disable posted mode
2). Use static dependency between timer clock domain and MPUSS clock
domain
3). Use no-idle mode when the timer is active
Workarounds #2 and #3 are not pratical from a power standpoint and so
workaround #1 has been implemented. Disabling posted mode adds some CPU
overhead for configuring and reading the timers as the CPU has to wait
for accesses to be re-synchronised within the timer. However, disabling
posted mode guarantees correct operation.
Please note that it is safe to use posted mode for timers if the counter
(TCRR) and capture (TCARx) registers will never be read. An example of
this is the clock-event system timer. This is used by the kernel to
schedule events however, the timers counter is never read and capture
registers are not used. Given that the kernel configures this timer
often yet never reads the counter register it is safe to enable posted
mode in this case. Hence, for the timer used for kernel clock-events,
posted mode is enabled by overriding the errata for devices that are
impacted by this defect.
For drivers using the timers that do not read the counter or capture
registers and wish to use posted mode, can override the errata and
enable posted mode by making the following function calls.
__omap_dm_timer_override_errata(timer, OMAP_TIMER_ERRATA_I103_I767);
__omap_dm_timer_enable_posted(timer);
Both dmtimers and watchdogs are impacted by this defect this patch only
implements the workaround for the dmtimer. Currently the watchdog driver
does not read the counter register and so no workaround is necessary.
Posted mode will be disabled for all OMAP2+ devices (including AM33xx)
using a GP timer as a clock-source timer to guarantee correct operation.
This is not necessary for OMAP24xx devices but the default clock-source
timer for OMAP24xx devices is the 32k-sync timer and not the GP timer
and so should not have any impact. This should be re-visited for future
devices if this errata is fixed.
Confirmed with Vaibhav Hiremath that this bug also impacts AM33xx
devices.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
2012-09-28 01:47:43 +08:00
|
|
|
/**
|
|
|
|
* omap_dm_timer_get_errata - get errata flags for a timer
|
|
|
|
*
|
|
|
|
* Get the timer errata flags that are specific to the OMAP device being used.
|
|
|
|
*/
|
2012-11-29 05:56:41 +08:00
|
|
|
static u32 __init omap_dm_timer_get_errata(void)
|
ARM: OMAP3+: Implement timer workaround for errata i103 and i767
Errata Titles:
i103: Delay needed to read some GP timer, WD timer and sync timer
registers after wakeup (OMAP3/4)
i767: Delay needed to read some GP timer registers after wakeup (OMAP5)
Description (i103/i767):
If a General Purpose Timer (GPTimer) is in posted mode
(TSICR [2].POSTED=1), due to internal resynchronizations, values read in
TCRR, TCAR1 and TCAR2 registers right after the timer interface clock
(L4) goes from stopped to active may not return the expected values. The
most common event leading to this situation occurs upon wake up from
idle.
GPTimer non-posted synchronization mode is not impacted by this
limitation.
Workarounds:
1). Disable posted mode
2). Use static dependency between timer clock domain and MPUSS clock
domain
3). Use no-idle mode when the timer is active
Workarounds #2 and #3 are not pratical from a power standpoint and so
workaround #1 has been implemented. Disabling posted mode adds some CPU
overhead for configuring and reading the timers as the CPU has to wait
for accesses to be re-synchronised within the timer. However, disabling
posted mode guarantees correct operation.
Please note that it is safe to use posted mode for timers if the counter
(TCRR) and capture (TCARx) registers will never be read. An example of
this is the clock-event system timer. This is used by the kernel to
schedule events however, the timers counter is never read and capture
registers are not used. Given that the kernel configures this timer
often yet never reads the counter register it is safe to enable posted
mode in this case. Hence, for the timer used for kernel clock-events,
posted mode is enabled by overriding the errata for devices that are
impacted by this defect.
For drivers using the timers that do not read the counter or capture
registers and wish to use posted mode, can override the errata and
enable posted mode by making the following function calls.
__omap_dm_timer_override_errata(timer, OMAP_TIMER_ERRATA_I103_I767);
__omap_dm_timer_enable_posted(timer);
Both dmtimers and watchdogs are impacted by this defect this patch only
implements the workaround for the dmtimer. Currently the watchdog driver
does not read the counter register and so no workaround is necessary.
Posted mode will be disabled for all OMAP2+ devices (including AM33xx)
using a GP timer as a clock-source timer to guarantee correct operation.
This is not necessary for OMAP24xx devices but the default clock-source
timer for OMAP24xx devices is the 32k-sync timer and not the GP timer
and so should not have any impact. This should be re-visited for future
devices if this errata is fixed.
Confirmed with Vaibhav Hiremath that this bug also impacts AM33xx
devices.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
2012-09-28 01:47:43 +08:00
|
|
|
{
|
|
|
|
if (cpu_is_omap24xx())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return OMAP_TIMER_ERRATA_I103_I767;
|
|
|
|
}
|
|
|
|
|
2011-03-30 06:54:48 +08:00
|
|
|
static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer,
|
2013-01-30 03:55:25 +08:00
|
|
|
const char *fck_source,
|
|
|
|
const char *property,
|
|
|
|
const char **timer_name,
|
|
|
|
int posted)
|
2007-11-13 15:24:02 +08:00
|
|
|
{
|
2013-05-28 14:24:48 +08:00
|
|
|
const char *oh_name = NULL;
|
ARM: OMAP: Add DT support for timer driver
In order to add device-tree support to the timer driver the following changes
were made ...
1. Allocate system timers (used for clock-events and clock-source) based upon
timer properties rather than using an hard-coded timer instance ID. To allow
this a new helper function called omap_dmtimer_find_by_property() has been
added for finding a timer with the particular properties in the device-tree
blob. Please note that this is an internal helper function for system timers
only to find a timer in the device-tree blob. This cannot be used by device
drivers, another API has been added for that (see below). Timers that are
allocated for system timers are dynamically disabled at boot time by adding
a status property with the value "disabled" to the timer's device-tree node.
Please note that when allocating system timers we now pass a timer ID and
timer property. The timer ID is only be used for allocating a timer when
booting without device-tree. Once device-tree migration is complete, all
the timer ID references will be removed.
2. System timer resources (memory and interrupts) are directly obtained from
the device-tree timer node when booting with device-tree, so that system
timers are no longer reliant upon the OMAP HWMOD framework to provide these
resources.
3. If DT blob is present, then let device-tree create the timer devices
dynamically.
4. When device-tree is present the "id" field in the platform_device structure
(pdev->id) is initialised to -1 and hence cannot be used to identify a timer
instance. Due to this the following changes were made ...
a). The API omap_dm_timer_request_specific() is not supported when using
device-tree, because it uses the device ID to request a specific timer.
This function will return an error if called when device-tree is present.
Users of this API should use omap_dm_timer_request_by_cap() instead.
b). When removing the DMTIMER driver, the timer "id" was used to identify the
timer instance. The remove function has been modified to use the device
name instead of the "id".
5. When device-tree is present the platform_data structure will be NULL and so
check for this.
6. The OMAP timer device tree binding has the following optional parameters ...
a). ti,timer-alwon --> Timer is in an always-on power domain
b). ti,timer-dsp --> Timer can generate an interrupt to the on-chip DSP
c). ti,timer-pwm --> Timer can generate a PWM output
d). ti,timer-secure --> Timer is reserved on a secure OMAP device
Search for the above parameters and set the appropriate timer attribute
flags.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
2012-05-14 23:41:37 +08:00
|
|
|
struct device_node *np;
|
2011-03-30 06:54:48 +08:00
|
|
|
struct omap_hwmod *oh;
|
2013-03-13 06:17:57 +08:00
|
|
|
struct clk *src;
|
2012-11-10 07:07:39 +08:00
|
|
|
int r = 0;
|
2011-03-30 06:54:48 +08:00
|
|
|
|
2017-06-01 06:51:30 +08:00
|
|
|
np = omap_get_timer_dt(omap_timer_match, property);
|
|
|
|
if (!np)
|
|
|
|
return -ENODEV;
|
ARM: OMAP: Add DT support for timer driver
In order to add device-tree support to the timer driver the following changes
were made ...
1. Allocate system timers (used for clock-events and clock-source) based upon
timer properties rather than using an hard-coded timer instance ID. To allow
this a new helper function called omap_dmtimer_find_by_property() has been
added for finding a timer with the particular properties in the device-tree
blob. Please note that this is an internal helper function for system timers
only to find a timer in the device-tree blob. This cannot be used by device
drivers, another API has been added for that (see below). Timers that are
allocated for system timers are dynamically disabled at boot time by adding
a status property with the value "disabled" to the timer's device-tree node.
Please note that when allocating system timers we now pass a timer ID and
timer property. The timer ID is only be used for allocating a timer when
booting without device-tree. Once device-tree migration is complete, all
the timer ID references will be removed.
2. System timer resources (memory and interrupts) are directly obtained from
the device-tree timer node when booting with device-tree, so that system
timers are no longer reliant upon the OMAP HWMOD framework to provide these
resources.
3. If DT blob is present, then let device-tree create the timer devices
dynamically.
4. When device-tree is present the "id" field in the platform_device structure
(pdev->id) is initialised to -1 and hence cannot be used to identify a timer
instance. Due to this the following changes were made ...
a). The API omap_dm_timer_request_specific() is not supported when using
device-tree, because it uses the device ID to request a specific timer.
This function will return an error if called when device-tree is present.
Users of this API should use omap_dm_timer_request_by_cap() instead.
b). When removing the DMTIMER driver, the timer "id" was used to identify the
timer instance. The remove function has been modified to use the device
name instead of the "id".
5. When device-tree is present the platform_data structure will be NULL and so
check for this.
6. The OMAP timer device tree binding has the following optional parameters ...
a). ti,timer-alwon --> Timer is in an always-on power domain
b). ti,timer-dsp --> Timer can generate an interrupt to the on-chip DSP
c). ti,timer-pwm --> Timer can generate a PWM output
d). ti,timer-secure --> Timer is reserved on a secure OMAP device
Search for the above parameters and set the appropriate timer attribute
flags.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
2012-05-14 23:41:37 +08:00
|
|
|
|
2017-06-01 06:51:30 +08:00
|
|
|
of_property_read_string_index(np, "ti,hwmods", 0, &oh_name);
|
2018-04-17 01:21:39 +08:00
|
|
|
if (!oh_name) {
|
|
|
|
of_property_read_string_index(np->parent, "ti,hwmods", 0,
|
|
|
|
&oh_name);
|
|
|
|
if (!oh_name)
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
ARM: OMAP: Add DT support for timer driver
In order to add device-tree support to the timer driver the following changes
were made ...
1. Allocate system timers (used for clock-events and clock-source) based upon
timer properties rather than using an hard-coded timer instance ID. To allow
this a new helper function called omap_dmtimer_find_by_property() has been
added for finding a timer with the particular properties in the device-tree
blob. Please note that this is an internal helper function for system timers
only to find a timer in the device-tree blob. This cannot be used by device
drivers, another API has been added for that (see below). Timers that are
allocated for system timers are dynamically disabled at boot time by adding
a status property with the value "disabled" to the timer's device-tree node.
Please note that when allocating system timers we now pass a timer ID and
timer property. The timer ID is only be used for allocating a timer when
booting without device-tree. Once device-tree migration is complete, all
the timer ID references will be removed.
2. System timer resources (memory and interrupts) are directly obtained from
the device-tree timer node when booting with device-tree, so that system
timers are no longer reliant upon the OMAP HWMOD framework to provide these
resources.
3. If DT blob is present, then let device-tree create the timer devices
dynamically.
4. When device-tree is present the "id" field in the platform_device structure
(pdev->id) is initialised to -1 and hence cannot be used to identify a timer
instance. Due to this the following changes were made ...
a). The API omap_dm_timer_request_specific() is not supported when using
device-tree, because it uses the device ID to request a specific timer.
This function will return an error if called when device-tree is present.
Users of this API should use omap_dm_timer_request_by_cap() instead.
b). When removing the DMTIMER driver, the timer "id" was used to identify the
timer instance. The remove function has been modified to use the device
name instead of the "id".
5. When device-tree is present the platform_data structure will be NULL and so
check for this.
6. The OMAP timer device tree binding has the following optional parameters ...
a). ti,timer-alwon --> Timer is in an always-on power domain
b). ti,timer-dsp --> Timer can generate an interrupt to the on-chip DSP
c). ti,timer-pwm --> Timer can generate a PWM output
d). ti,timer-secure --> Timer is reserved on a secure OMAP device
Search for the above parameters and set the appropriate timer attribute
flags.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
2012-05-14 23:41:37 +08:00
|
|
|
|
2017-06-01 06:51:30 +08:00
|
|
|
timer->irq = irq_of_parse_and_map(np, 0);
|
|
|
|
if (!timer->irq)
|
|
|
|
return -ENXIO;
|
ARM: OMAP: Add DT support for timer driver
In order to add device-tree support to the timer driver the following changes
were made ...
1. Allocate system timers (used for clock-events and clock-source) based upon
timer properties rather than using an hard-coded timer instance ID. To allow
this a new helper function called omap_dmtimer_find_by_property() has been
added for finding a timer with the particular properties in the device-tree
blob. Please note that this is an internal helper function for system timers
only to find a timer in the device-tree blob. This cannot be used by device
drivers, another API has been added for that (see below). Timers that are
allocated for system timers are dynamically disabled at boot time by adding
a status property with the value "disabled" to the timer's device-tree node.
Please note that when allocating system timers we now pass a timer ID and
timer property. The timer ID is only be used for allocating a timer when
booting without device-tree. Once device-tree migration is complete, all
the timer ID references will be removed.
2. System timer resources (memory and interrupts) are directly obtained from
the device-tree timer node when booting with device-tree, so that system
timers are no longer reliant upon the OMAP HWMOD framework to provide these
resources.
3. If DT blob is present, then let device-tree create the timer devices
dynamically.
4. When device-tree is present the "id" field in the platform_device structure
(pdev->id) is initialised to -1 and hence cannot be used to identify a timer
instance. Due to this the following changes were made ...
a). The API omap_dm_timer_request_specific() is not supported when using
device-tree, because it uses the device ID to request a specific timer.
This function will return an error if called when device-tree is present.
Users of this API should use omap_dm_timer_request_by_cap() instead.
b). When removing the DMTIMER driver, the timer "id" was used to identify the
timer instance. The remove function has been modified to use the device
name instead of the "id".
5. When device-tree is present the platform_data structure will be NULL and so
check for this.
6. The OMAP timer device tree binding has the following optional parameters ...
a). ti,timer-alwon --> Timer is in an always-on power domain
b). ti,timer-dsp --> Timer can generate an interrupt to the on-chip DSP
c). ti,timer-pwm --> Timer can generate a PWM output
d). ti,timer-secure --> Timer is reserved on a secure OMAP device
Search for the above parameters and set the appropriate timer attribute
flags.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
2012-05-14 23:41:37 +08:00
|
|
|
|
2017-06-01 06:51:30 +08:00
|
|
|
timer->io_base = of_iomap(np, 0);
|
ARM: OMAP: Add DT support for timer driver
In order to add device-tree support to the timer driver the following changes
were made ...
1. Allocate system timers (used for clock-events and clock-source) based upon
timer properties rather than using an hard-coded timer instance ID. To allow
this a new helper function called omap_dmtimer_find_by_property() has been
added for finding a timer with the particular properties in the device-tree
blob. Please note that this is an internal helper function for system timers
only to find a timer in the device-tree blob. This cannot be used by device
drivers, another API has been added for that (see below). Timers that are
allocated for system timers are dynamically disabled at boot time by adding
a status property with the value "disabled" to the timer's device-tree node.
Please note that when allocating system timers we now pass a timer ID and
timer property. The timer ID is only be used for allocating a timer when
booting without device-tree. Once device-tree migration is complete, all
the timer ID references will be removed.
2. System timer resources (memory and interrupts) are directly obtained from
the device-tree timer node when booting with device-tree, so that system
timers are no longer reliant upon the OMAP HWMOD framework to provide these
resources.
3. If DT blob is present, then let device-tree create the timer devices
dynamically.
4. When device-tree is present the "id" field in the platform_device structure
(pdev->id) is initialised to -1 and hence cannot be used to identify a timer
instance. Due to this the following changes were made ...
a). The API omap_dm_timer_request_specific() is not supported when using
device-tree, because it uses the device ID to request a specific timer.
This function will return an error if called when device-tree is present.
Users of this API should use omap_dm_timer_request_by_cap() instead.
b). When removing the DMTIMER driver, the timer "id" was used to identify the
timer instance. The remove function has been modified to use the device
name instead of the "id".
5. When device-tree is present the platform_data structure will be NULL and so
check for this.
6. The OMAP timer device tree binding has the following optional parameters ...
a). ti,timer-alwon --> Timer is in an always-on power domain
b). ti,timer-dsp --> Timer can generate an interrupt to the on-chip DSP
c). ti,timer-pwm --> Timer can generate a PWM output
d). ti,timer-secure --> Timer is reserved on a secure OMAP device
Search for the above parameters and set the appropriate timer attribute
flags.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
2012-05-14 23:41:37 +08:00
|
|
|
|
2017-06-12 18:27:30 +08:00
|
|
|
timer->fclk = of_clk_get_by_name(np, "fck");
|
ARM: OMAP: Add DT support for timer driver
In order to add device-tree support to the timer driver the following changes
were made ...
1. Allocate system timers (used for clock-events and clock-source) based upon
timer properties rather than using an hard-coded timer instance ID. To allow
this a new helper function called omap_dmtimer_find_by_property() has been
added for finding a timer with the particular properties in the device-tree
blob. Please note that this is an internal helper function for system timers
only to find a timer in the device-tree blob. This cannot be used by device
drivers, another API has been added for that (see below). Timers that are
allocated for system timers are dynamically disabled at boot time by adding
a status property with the value "disabled" to the timer's device-tree node.
Please note that when allocating system timers we now pass a timer ID and
timer property. The timer ID is only be used for allocating a timer when
booting without device-tree. Once device-tree migration is complete, all
the timer ID references will be removed.
2. System timer resources (memory and interrupts) are directly obtained from
the device-tree timer node when booting with device-tree, so that system
timers are no longer reliant upon the OMAP HWMOD framework to provide these
resources.
3. If DT blob is present, then let device-tree create the timer devices
dynamically.
4. When device-tree is present the "id" field in the platform_device structure
(pdev->id) is initialised to -1 and hence cannot be used to identify a timer
instance. Due to this the following changes were made ...
a). The API omap_dm_timer_request_specific() is not supported when using
device-tree, because it uses the device ID to request a specific timer.
This function will return an error if called when device-tree is present.
Users of this API should use omap_dm_timer_request_by_cap() instead.
b). When removing the DMTIMER driver, the timer "id" was used to identify the
timer instance. The remove function has been modified to use the device
name instead of the "id".
5. When device-tree is present the platform_data structure will be NULL and so
check for this.
6. The OMAP timer device tree binding has the following optional parameters ...
a). ti,timer-alwon --> Timer is in an always-on power domain
b). ti,timer-dsp --> Timer can generate an interrupt to the on-chip DSP
c). ti,timer-pwm --> Timer can generate a PWM output
d). ti,timer-secure --> Timer is reserved on a secure OMAP device
Search for the above parameters and set the appropriate timer attribute
flags.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
2012-05-14 23:41:37 +08:00
|
|
|
|
2017-06-01 06:51:30 +08:00
|
|
|
of_node_put(np);
|
ARM: OMAP: Add DT support for timer driver
In order to add device-tree support to the timer driver the following changes
were made ...
1. Allocate system timers (used for clock-events and clock-source) based upon
timer properties rather than using an hard-coded timer instance ID. To allow
this a new helper function called omap_dmtimer_find_by_property() has been
added for finding a timer with the particular properties in the device-tree
blob. Please note that this is an internal helper function for system timers
only to find a timer in the device-tree blob. This cannot be used by device
drivers, another API has been added for that (see below). Timers that are
allocated for system timers are dynamically disabled at boot time by adding
a status property with the value "disabled" to the timer's device-tree node.
Please note that when allocating system timers we now pass a timer ID and
timer property. The timer ID is only be used for allocating a timer when
booting without device-tree. Once device-tree migration is complete, all
the timer ID references will be removed.
2. System timer resources (memory and interrupts) are directly obtained from
the device-tree timer node when booting with device-tree, so that system
timers are no longer reliant upon the OMAP HWMOD framework to provide these
resources.
3. If DT blob is present, then let device-tree create the timer devices
dynamically.
4. When device-tree is present the "id" field in the platform_device structure
(pdev->id) is initialised to -1 and hence cannot be used to identify a timer
instance. Due to this the following changes were made ...
a). The API omap_dm_timer_request_specific() is not supported when using
device-tree, because it uses the device ID to request a specific timer.
This function will return an error if called when device-tree is present.
Users of this API should use omap_dm_timer_request_by_cap() instead.
b). When removing the DMTIMER driver, the timer "id" was used to identify the
timer instance. The remove function has been modified to use the device
name instead of the "id".
5. When device-tree is present the platform_data structure will be NULL and so
check for this.
6. The OMAP timer device tree binding has the following optional parameters ...
a). ti,timer-alwon --> Timer is in an always-on power domain
b). ti,timer-dsp --> Timer can generate an interrupt to the on-chip DSP
c). ti,timer-pwm --> Timer can generate a PWM output
d). ti,timer-secure --> Timer is reserved on a secure OMAP device
Search for the above parameters and set the appropriate timer attribute
flags.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
2012-05-14 23:41:37 +08:00
|
|
|
|
|
|
|
oh = omap_hwmod_lookup(oh_name);
|
2011-03-30 06:54:48 +08:00
|
|
|
if (!oh)
|
|
|
|
return -ENODEV;
|
|
|
|
|
2013-01-30 03:55:25 +08:00
|
|
|
*timer_name = oh->name;
|
|
|
|
|
2011-03-30 06:54:48 +08:00
|
|
|
if (!timer->io_base)
|
|
|
|
return -ENXIO;
|
|
|
|
|
2016-06-30 21:15:01 +08:00
|
|
|
omap_hwmod_setup_one(oh_name);
|
|
|
|
|
2011-03-30 06:54:48 +08:00
|
|
|
/* After the dmtimer is using hwmod these clocks won't be needed */
|
2017-05-31 22:59:58 +08:00
|
|
|
if (IS_ERR_OR_NULL(timer->fclk))
|
|
|
|
timer->fclk = clk_get(NULL, omap_hwmod_get_main_clk(oh));
|
2011-03-30 06:54:48 +08:00
|
|
|
if (IS_ERR(timer->fclk))
|
2013-03-13 06:17:57 +08:00
|
|
|
return PTR_ERR(timer->fclk);
|
2011-03-30 06:54:48 +08:00
|
|
|
|
2013-03-13 06:17:57 +08:00
|
|
|
src = clk_get(NULL, fck_source);
|
|
|
|
if (IS_ERR(src))
|
|
|
|
return PTR_ERR(src);
|
2011-03-30 06:54:48 +08:00
|
|
|
|
2015-09-02 04:59:25 +08:00
|
|
|
WARN(clk_set_parent(timer->fclk, src) < 0,
|
|
|
|
"Cannot set timer parent clock, no PLL clock driver?");
|
2012-09-29 00:43:30 +08:00
|
|
|
|
2013-03-13 06:17:57 +08:00
|
|
|
clk_put(src);
|
|
|
|
|
2012-09-29 00:43:30 +08:00
|
|
|
omap_hwmod_enable(oh);
|
2011-09-17 06:44:20 +08:00
|
|
|
__omap_dm_timer_init_regs(timer);
|
2011-03-30 06:54:48 +08:00
|
|
|
|
ARM: OMAP3+: Implement timer workaround for errata i103 and i767
Errata Titles:
i103: Delay needed to read some GP timer, WD timer and sync timer
registers after wakeup (OMAP3/4)
i767: Delay needed to read some GP timer registers after wakeup (OMAP5)
Description (i103/i767):
If a General Purpose Timer (GPTimer) is in posted mode
(TSICR [2].POSTED=1), due to internal resynchronizations, values read in
TCRR, TCAR1 and TCAR2 registers right after the timer interface clock
(L4) goes from stopped to active may not return the expected values. The
most common event leading to this situation occurs upon wake up from
idle.
GPTimer non-posted synchronization mode is not impacted by this
limitation.
Workarounds:
1). Disable posted mode
2). Use static dependency between timer clock domain and MPUSS clock
domain
3). Use no-idle mode when the timer is active
Workarounds #2 and #3 are not pratical from a power standpoint and so
workaround #1 has been implemented. Disabling posted mode adds some CPU
overhead for configuring and reading the timers as the CPU has to wait
for accesses to be re-synchronised within the timer. However, disabling
posted mode guarantees correct operation.
Please note that it is safe to use posted mode for timers if the counter
(TCRR) and capture (TCARx) registers will never be read. An example of
this is the clock-event system timer. This is used by the kernel to
schedule events however, the timers counter is never read and capture
registers are not used. Given that the kernel configures this timer
often yet never reads the counter register it is safe to enable posted
mode in this case. Hence, for the timer used for kernel clock-events,
posted mode is enabled by overriding the errata for devices that are
impacted by this defect.
For drivers using the timers that do not read the counter or capture
registers and wish to use posted mode, can override the errata and
enable posted mode by making the following function calls.
__omap_dm_timer_override_errata(timer, OMAP_TIMER_ERRATA_I103_I767);
__omap_dm_timer_enable_posted(timer);
Both dmtimers and watchdogs are impacted by this defect this patch only
implements the workaround for the dmtimer. Currently the watchdog driver
does not read the counter register and so no workaround is necessary.
Posted mode will be disabled for all OMAP2+ devices (including AM33xx)
using a GP timer as a clock-source timer to guarantee correct operation.
This is not necessary for OMAP24xx devices but the default clock-source
timer for OMAP24xx devices is the 32k-sync timer and not the GP timer
and so should not have any impact. This should be re-visited for future
devices if this errata is fixed.
Confirmed with Vaibhav Hiremath that this bug also impacts AM33xx
devices.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
2012-09-28 01:47:43 +08:00
|
|
|
if (posted)
|
|
|
|
__omap_dm_timer_enable_posted(timer);
|
|
|
|
|
|
|
|
/* Check that the intended posted configuration matches the actual */
|
|
|
|
if (posted != timer->posted)
|
|
|
|
return -EINVAL;
|
2005-11-10 22:26:51 +08:00
|
|
|
|
ARM: OMAP3+: Implement timer workaround for errata i103 and i767
Errata Titles:
i103: Delay needed to read some GP timer, WD timer and sync timer
registers after wakeup (OMAP3/4)
i767: Delay needed to read some GP timer registers after wakeup (OMAP5)
Description (i103/i767):
If a General Purpose Timer (GPTimer) is in posted mode
(TSICR [2].POSTED=1), due to internal resynchronizations, values read in
TCRR, TCAR1 and TCAR2 registers right after the timer interface clock
(L4) goes from stopped to active may not return the expected values. The
most common event leading to this situation occurs upon wake up from
idle.
GPTimer non-posted synchronization mode is not impacted by this
limitation.
Workarounds:
1). Disable posted mode
2). Use static dependency between timer clock domain and MPUSS clock
domain
3). Use no-idle mode when the timer is active
Workarounds #2 and #3 are not pratical from a power standpoint and so
workaround #1 has been implemented. Disabling posted mode adds some CPU
overhead for configuring and reading the timers as the CPU has to wait
for accesses to be re-synchronised within the timer. However, disabling
posted mode guarantees correct operation.
Please note that it is safe to use posted mode for timers if the counter
(TCRR) and capture (TCARx) registers will never be read. An example of
this is the clock-event system timer. This is used by the kernel to
schedule events however, the timers counter is never read and capture
registers are not used. Given that the kernel configures this timer
often yet never reads the counter register it is safe to enable posted
mode in this case. Hence, for the timer used for kernel clock-events,
posted mode is enabled by overriding the errata for devices that are
impacted by this defect.
For drivers using the timers that do not read the counter or capture
registers and wish to use posted mode, can override the errata and
enable posted mode by making the following function calls.
__omap_dm_timer_override_errata(timer, OMAP_TIMER_ERRATA_I103_I767);
__omap_dm_timer_enable_posted(timer);
Both dmtimers and watchdogs are impacted by this defect this patch only
implements the workaround for the dmtimer. Currently the watchdog driver
does not read the counter register and so no workaround is necessary.
Posted mode will be disabled for all OMAP2+ devices (including AM33xx)
using a GP timer as a clock-source timer to guarantee correct operation.
This is not necessary for OMAP24xx devices but the default clock-source
timer for OMAP24xx devices is the 32k-sync timer and not the GP timer
and so should not have any impact. This should be re-visited for future
devices if this errata is fixed.
Confirmed with Vaibhav Hiremath that this bug also impacts AM33xx
devices.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
2012-09-28 01:47:43 +08:00
|
|
|
timer->rate = clk_get_rate(timer->fclk);
|
2011-03-30 06:54:48 +08:00
|
|
|
timer->reserved = 1;
|
2011-02-23 15:14:08 +08:00
|
|
|
|
2012-11-10 07:07:39 +08:00
|
|
|
return r;
|
2011-03-30 06:54:48 +08:00
|
|
|
}
|
OMAP2/3 GPTIMER: allow system tick GPTIMER to be changed in board-*.c files
Add a function omap2_gp_clockevent_set_gptimer() for board-*.c files
to use in .init_irq functions to configure the system tick GPTIMER.
Practical choices at this point are GPTIMER1 or GPTIMER12. Both of
these timers are in the WKUP powerdomain, and so are unaffected by
chip power management. GPTIMER1 can use sys_clk as a source, for
applications where a high-resolution timer is more important than
power management. GPTIMER12 has the special property that it has the
secure 32kHz oscillator as its source clock, which may be less prone
to glitches than the off-chip 32kHz oscillator. But on HS devices, it
may not be available for Linux use.
It appears that most boards are fine with GPTIMER1, but BeagleBoard
should use GPTIMER12 when using a 32KiHz timer source, due to hardware bugs
in revisions B4 and below. Modify board-omap3beagle.c to use GPTIMER12.
This patch originally used a Kbuild config option to select the GPTIMER,
but was changed to allow this to be specified in board-*.c files, per
Tony's request.
Kalle Vallo <kalle.valo@nokia.com> found a bug in an earlier version of
this patch - thanks Kalle.
Tested on Beagle rev B4 ES2.1, with and without CONFIG_OMAP_32K_TIMER, and
3430SDP.
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Cc: Kalle Valo <kalle.valo@nokia.com>
2009-04-24 11:11:10 +08:00
|
|
|
|
2015-12-15 04:34:05 +08:00
|
|
|
#if !defined(CONFIG_SMP) && defined(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST)
|
|
|
|
void tick_broadcast(const struct cpumask *mask)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2024-06-12 13:13:20 +08:00
|
|
|
static void __init dmtimer_clkevt_init_common(struct dmtimer_clockevent *clkevt,
|
|
|
|
int gptimer_id,
|
|
|
|
const char *fck_source,
|
|
|
|
unsigned int features,
|
|
|
|
const struct cpumask *cpumask,
|
|
|
|
const char *property,
|
|
|
|
int rating, const char *name)
|
2011-03-30 06:54:48 +08:00
|
|
|
{
|
2024-06-12 13:13:20 +08:00
|
|
|
struct omap_dm_timer *timer = &clkevt->timer;
|
2011-03-30 06:54:48 +08:00
|
|
|
int res;
|
OMAP2/3 GPTIMER: allow system tick GPTIMER to be changed in board-*.c files
Add a function omap2_gp_clockevent_set_gptimer() for board-*.c files
to use in .init_irq functions to configure the system tick GPTIMER.
Practical choices at this point are GPTIMER1 or GPTIMER12. Both of
these timers are in the WKUP powerdomain, and so are unaffected by
chip power management. GPTIMER1 can use sys_clk as a source, for
applications where a high-resolution timer is more important than
power management. GPTIMER12 has the special property that it has the
secure 32kHz oscillator as its source clock, which may be less prone
to glitches than the off-chip 32kHz oscillator. But on HS devices, it
may not be available for Linux use.
It appears that most boards are fine with GPTIMER1, but BeagleBoard
should use GPTIMER12 when using a 32KiHz timer source, due to hardware bugs
in revisions B4 and below. Modify board-omap3beagle.c to use GPTIMER12.
This patch originally used a Kbuild config option to select the GPTIMER,
but was changed to allow this to be specified in board-*.c files, per
Tony's request.
Kalle Vallo <kalle.valo@nokia.com> found a bug in an earlier version of
this patch - thanks Kalle.
Tested on Beagle rev B4 ES2.1, with and without CONFIG_OMAP_32K_TIMER, and
3430SDP.
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Cc: Kalle Valo <kalle.valo@nokia.com>
2009-04-24 11:11:10 +08:00
|
|
|
|
2024-06-12 13:13:20 +08:00
|
|
|
timer->id = gptimer_id;
|
|
|
|
timer->errata = omap_dm_timer_get_errata();
|
|
|
|
clkevt->dev.features = features;
|
|
|
|
clkevt->dev.rating = rating;
|
|
|
|
clkevt->dev.set_next_event = omap2_gp_timer_set_next_event;
|
|
|
|
clkevt->dev.set_state_shutdown = omap2_gp_timer_shutdown;
|
|
|
|
clkevt->dev.set_state_periodic = omap2_gp_timer_set_periodic;
|
|
|
|
clkevt->dev.set_state_oneshot = omap2_gp_timer_shutdown;
|
|
|
|
clkevt->dev.tick_resume = omap2_gp_timer_shutdown;
|
ARM: OMAP3+: Implement timer workaround for errata i103 and i767
Errata Titles:
i103: Delay needed to read some GP timer, WD timer and sync timer
registers after wakeup (OMAP3/4)
i767: Delay needed to read some GP timer registers after wakeup (OMAP5)
Description (i103/i767):
If a General Purpose Timer (GPTimer) is in posted mode
(TSICR [2].POSTED=1), due to internal resynchronizations, values read in
TCRR, TCAR1 and TCAR2 registers right after the timer interface clock
(L4) goes from stopped to active may not return the expected values. The
most common event leading to this situation occurs upon wake up from
idle.
GPTimer non-posted synchronization mode is not impacted by this
limitation.
Workarounds:
1). Disable posted mode
2). Use static dependency between timer clock domain and MPUSS clock
domain
3). Use no-idle mode when the timer is active
Workarounds #2 and #3 are not pratical from a power standpoint and so
workaround #1 has been implemented. Disabling posted mode adds some CPU
overhead for configuring and reading the timers as the CPU has to wait
for accesses to be re-synchronised within the timer. However, disabling
posted mode guarantees correct operation.
Please note that it is safe to use posted mode for timers if the counter
(TCRR) and capture (TCARx) registers will never be read. An example of
this is the clock-event system timer. This is used by the kernel to
schedule events however, the timers counter is never read and capture
registers are not used. Given that the kernel configures this timer
often yet never reads the counter register it is safe to enable posted
mode in this case. Hence, for the timer used for kernel clock-events,
posted mode is enabled by overriding the errata for devices that are
impacted by this defect.
For drivers using the timers that do not read the counter or capture
registers and wish to use posted mode, can override the errata and
enable posted mode by making the following function calls.
__omap_dm_timer_override_errata(timer, OMAP_TIMER_ERRATA_I103_I767);
__omap_dm_timer_enable_posted(timer);
Both dmtimers and watchdogs are impacted by this defect this patch only
implements the workaround for the dmtimer. Currently the watchdog driver
does not read the counter register and so no workaround is necessary.
Posted mode will be disabled for all OMAP2+ devices (including AM33xx)
using a GP timer as a clock-source timer to guarantee correct operation.
This is not necessary for OMAP24xx devices but the default clock-source
timer for OMAP24xx devices is the 32k-sync timer and not the GP timer
and so should not have any impact. This should be re-visited for future
devices if this errata is fixed.
Confirmed with Vaibhav Hiremath that this bug also impacts AM33xx
devices.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
2012-09-28 01:47:43 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* For clock-event timers we never read the timer counter and
|
|
|
|
* so we are not impacted by errata i103 and i767. Therefore,
|
|
|
|
* we can safely ignore this errata for clock-event timers.
|
|
|
|
*/
|
2024-06-12 13:13:20 +08:00
|
|
|
__omap_dm_timer_override_errata(timer, OMAP_TIMER_ERRATA_I103_I767);
|
ARM: OMAP3+: Implement timer workaround for errata i103 and i767
Errata Titles:
i103: Delay needed to read some GP timer, WD timer and sync timer
registers after wakeup (OMAP3/4)
i767: Delay needed to read some GP timer registers after wakeup (OMAP5)
Description (i103/i767):
If a General Purpose Timer (GPTimer) is in posted mode
(TSICR [2].POSTED=1), due to internal resynchronizations, values read in
TCRR, TCAR1 and TCAR2 registers right after the timer interface clock
(L4) goes from stopped to active may not return the expected values. The
most common event leading to this situation occurs upon wake up from
idle.
GPTimer non-posted synchronization mode is not impacted by this
limitation.
Workarounds:
1). Disable posted mode
2). Use static dependency between timer clock domain and MPUSS clock
domain
3). Use no-idle mode when the timer is active
Workarounds #2 and #3 are not pratical from a power standpoint and so
workaround #1 has been implemented. Disabling posted mode adds some CPU
overhead for configuring and reading the timers as the CPU has to wait
for accesses to be re-synchronised within the timer. However, disabling
posted mode guarantees correct operation.
Please note that it is safe to use posted mode for timers if the counter
(TCRR) and capture (TCARx) registers will never be read. An example of
this is the clock-event system timer. This is used by the kernel to
schedule events however, the timers counter is never read and capture
registers are not used. Given that the kernel configures this timer
often yet never reads the counter register it is safe to enable posted
mode in this case. Hence, for the timer used for kernel clock-events,
posted mode is enabled by overriding the errata for devices that are
impacted by this defect.
For drivers using the timers that do not read the counter or capture
registers and wish to use posted mode, can override the errata and
enable posted mode by making the following function calls.
__omap_dm_timer_override_errata(timer, OMAP_TIMER_ERRATA_I103_I767);
__omap_dm_timer_enable_posted(timer);
Both dmtimers and watchdogs are impacted by this defect this patch only
implements the workaround for the dmtimer. Currently the watchdog driver
does not read the counter register and so no workaround is necessary.
Posted mode will be disabled for all OMAP2+ devices (including AM33xx)
using a GP timer as a clock-source timer to guarantee correct operation.
This is not necessary for OMAP24xx devices but the default clock-source
timer for OMAP24xx devices is the 32k-sync timer and not the GP timer
and so should not have any impact. This should be re-visited for future
devices if this errata is fixed.
Confirmed with Vaibhav Hiremath that this bug also impacts AM33xx
devices.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
2012-09-28 01:47:43 +08:00
|
|
|
|
2024-06-12 13:13:20 +08:00
|
|
|
res = omap_dm_timer_init_one(timer, fck_source, property,
|
|
|
|
&clkevt->dev.name, OMAP_TIMER_POSTED);
|
2011-03-30 06:54:48 +08:00
|
|
|
BUG_ON(res);
|
OMAP2/3 GPTIMER: allow system tick GPTIMER to be changed in board-*.c files
Add a function omap2_gp_clockevent_set_gptimer() for board-*.c files
to use in .init_irq functions to configure the system tick GPTIMER.
Practical choices at this point are GPTIMER1 or GPTIMER12. Both of
these timers are in the WKUP powerdomain, and so are unaffected by
chip power management. GPTIMER1 can use sys_clk as a source, for
applications where a high-resolution timer is more important than
power management. GPTIMER12 has the special property that it has the
secure 32kHz oscillator as its source clock, which may be less prone
to glitches than the off-chip 32kHz oscillator. But on HS devices, it
may not be available for Linux use.
It appears that most boards are fine with GPTIMER1, but BeagleBoard
should use GPTIMER12 when using a 32KiHz timer source, due to hardware bugs
in revisions B4 and below. Modify board-omap3beagle.c to use GPTIMER12.
This patch originally used a Kbuild config option to select the GPTIMER,
but was changed to allow this to be specified in board-*.c files, per
Tony's request.
Kalle Vallo <kalle.valo@nokia.com> found a bug in an earlier version of
this patch - thanks Kalle.
Tested on Beagle rev B4 ES2.1, with and without CONFIG_OMAP_32K_TIMER, and
3430SDP.
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Cc: Kalle Valo <kalle.valo@nokia.com>
2009-04-24 11:11:10 +08:00
|
|
|
|
2024-06-12 13:13:20 +08:00
|
|
|
clkevt->dev.cpumask = cpumask;
|
|
|
|
clkevt->dev.irq = omap_dm_timer_get_irq(timer);
|
2007-11-13 15:24:02 +08:00
|
|
|
|
2024-06-12 13:13:20 +08:00
|
|
|
if (request_irq(clkevt->dev.irq, omap2_gp_timer_interrupt,
|
|
|
|
IRQF_TIMER | IRQF_IRQPOLL, name, clkevt))
|
|
|
|
pr_err("Failed to request irq %d (gp_timer)\n", clkevt->dev.irq);
|
2011-03-30 06:54:48 +08:00
|
|
|
|
2024-06-12 13:13:20 +08:00
|
|
|
__omap_dm_timer_int_enable(timer, OMAP_TIMER_INT_OVERFLOW);
|
2011-03-30 06:54:48 +08:00
|
|
|
|
2017-03-29 09:57:55 +08:00
|
|
|
if (soc_is_am33xx() || soc_is_am43xx()) {
|
2024-06-12 13:13:20 +08:00
|
|
|
clkevt->dev.suspend = omap_clkevt_idle;
|
|
|
|
clkevt->dev.resume = omap_clkevt_unidle;
|
2017-03-29 09:57:55 +08:00
|
|
|
|
|
|
|
clockevent_gpt_hwmod =
|
2024-06-12 13:13:20 +08:00
|
|
|
omap_hwmod_lookup(clkevt->dev.name);
|
|
|
|
}
|
|
|
|
|
|
|
|
pr_info("OMAP clockevent source: %s at %lu Hz\n", clkevt->dev.name,
|
|
|
|
timer->rate);
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEFINE_PER_CPU(struct dmtimer_clockevent, dmtimer_percpu_timer);
|
|
|
|
|
|
|
|
static int omap_gptimer_starting_cpu(unsigned int cpu)
|
|
|
|
{
|
|
|
|
struct dmtimer_clockevent *clkevt = per_cpu_ptr(&dmtimer_percpu_timer, cpu);
|
|
|
|
struct clock_event_device *dev = &clkevt->dev;
|
|
|
|
struct omap_dm_timer *timer = &clkevt->timer;
|
|
|
|
|
|
|
|
clockevents_config_and_register(dev, timer->rate, 3, ULONG_MAX);
|
|
|
|
irq_force_affinity(dev->irq, cpumask_of(cpu));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init dmtimer_percpu_quirk_init(void)
|
|
|
|
{
|
|
|
|
struct dmtimer_clockevent *clkevt;
|
|
|
|
struct clock_event_device *dev;
|
|
|
|
struct device_node *arm_timer;
|
|
|
|
struct omap_dm_timer *timer;
|
|
|
|
int cpu = 0;
|
|
|
|
|
|
|
|
arm_timer = of_find_compatible_node(NULL, NULL, "arm,armv7-timer");
|
|
|
|
if (of_device_is_available(arm_timer)) {
|
|
|
|
pr_warn_once("ARM architected timer wrap issue i940 detected\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for_each_possible_cpu(cpu) {
|
|
|
|
clkevt = per_cpu_ptr(&dmtimer_percpu_timer, cpu);
|
|
|
|
dev = &clkevt->dev;
|
|
|
|
timer = &clkevt->timer;
|
|
|
|
|
|
|
|
dmtimer_clkevt_init_common(clkevt, 0, "timer_sys_ck",
|
|
|
|
CLOCK_EVT_FEAT_ONESHOT,
|
|
|
|
cpumask_of(cpu),
|
|
|
|
"assigned-clock-parents",
|
|
|
|
500, "percpu timer");
|
2017-03-29 09:57:55 +08:00
|
|
|
}
|
|
|
|
|
2024-06-12 13:13:20 +08:00
|
|
|
cpuhp_setup_state(CPUHP_AP_OMAP_DM_TIMER_STARTING,
|
|
|
|
"clockevents/omap/gptimer:starting",
|
|
|
|
omap_gptimer_starting_cpu, NULL);
|
|
|
|
|
|
|
|
return 0;
|
2007-11-13 15:24:02 +08:00
|
|
|
}
|
|
|
|
|
OMAP2/3 GPTIMER: allow system tick GPTIMER to be changed in board-*.c files
Add a function omap2_gp_clockevent_set_gptimer() for board-*.c files
to use in .init_irq functions to configure the system tick GPTIMER.
Practical choices at this point are GPTIMER1 or GPTIMER12. Both of
these timers are in the WKUP powerdomain, and so are unaffected by
chip power management. GPTIMER1 can use sys_clk as a source, for
applications where a high-resolution timer is more important than
power management. GPTIMER12 has the special property that it has the
secure 32kHz oscillator as its source clock, which may be less prone
to glitches than the off-chip 32kHz oscillator. But on HS devices, it
may not be available for Linux use.
It appears that most boards are fine with GPTIMER1, but BeagleBoard
should use GPTIMER12 when using a 32KiHz timer source, due to hardware bugs
in revisions B4 and below. Modify board-omap3beagle.c to use GPTIMER12.
This patch originally used a Kbuild config option to select the GPTIMER,
but was changed to allow this to be specified in board-*.c files, per
Tony's request.
Kalle Vallo <kalle.valo@nokia.com> found a bug in an earlier version of
this patch - thanks Kalle.
Tested on Beagle rev B4 ES2.1, with and without CONFIG_OMAP_32K_TIMER, and
3430SDP.
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Cc: Kalle Valo <kalle.valo@nokia.com>
2009-04-24 11:11:10 +08:00
|
|
|
/* Clocksource code */
|
2011-03-30 06:54:49 +08:00
|
|
|
static struct omap_dm_timer clksrc;
|
2014-04-15 00:49:30 +08:00
|
|
|
static bool use_gptimer_clksrc __initdata;
|
2011-03-30 06:54:49 +08:00
|
|
|
|
2007-11-13 15:24:02 +08:00
|
|
|
/*
|
|
|
|
* clocksource
|
|
|
|
*/
|
2016-12-22 03:32:01 +08:00
|
|
|
static u64 clocksource_read_cycles(struct clocksource *cs)
|
2007-11-13 15:24:02 +08:00
|
|
|
{
|
2016-12-22 03:32:01 +08:00
|
|
|
return (u64)__omap_dm_timer_read_counter(&clksrc,
|
ARM: OMAP3+: Implement timer workaround for errata i103 and i767
Errata Titles:
i103: Delay needed to read some GP timer, WD timer and sync timer
registers after wakeup (OMAP3/4)
i767: Delay needed to read some GP timer registers after wakeup (OMAP5)
Description (i103/i767):
If a General Purpose Timer (GPTimer) is in posted mode
(TSICR [2].POSTED=1), due to internal resynchronizations, values read in
TCRR, TCAR1 and TCAR2 registers right after the timer interface clock
(L4) goes from stopped to active may not return the expected values. The
most common event leading to this situation occurs upon wake up from
idle.
GPTimer non-posted synchronization mode is not impacted by this
limitation.
Workarounds:
1). Disable posted mode
2). Use static dependency between timer clock domain and MPUSS clock
domain
3). Use no-idle mode when the timer is active
Workarounds #2 and #3 are not pratical from a power standpoint and so
workaround #1 has been implemented. Disabling posted mode adds some CPU
overhead for configuring and reading the timers as the CPU has to wait
for accesses to be re-synchronised within the timer. However, disabling
posted mode guarantees correct operation.
Please note that it is safe to use posted mode for timers if the counter
(TCRR) and capture (TCARx) registers will never be read. An example of
this is the clock-event system timer. This is used by the kernel to
schedule events however, the timers counter is never read and capture
registers are not used. Given that the kernel configures this timer
often yet never reads the counter register it is safe to enable posted
mode in this case. Hence, for the timer used for kernel clock-events,
posted mode is enabled by overriding the errata for devices that are
impacted by this defect.
For drivers using the timers that do not read the counter or capture
registers and wish to use posted mode, can override the errata and
enable posted mode by making the following function calls.
__omap_dm_timer_override_errata(timer, OMAP_TIMER_ERRATA_I103_I767);
__omap_dm_timer_enable_posted(timer);
Both dmtimers and watchdogs are impacted by this defect this patch only
implements the workaround for the dmtimer. Currently the watchdog driver
does not read the counter register and so no workaround is necessary.
Posted mode will be disabled for all OMAP2+ devices (including AM33xx)
using a GP timer as a clock-source timer to guarantee correct operation.
This is not necessary for OMAP24xx devices but the default clock-source
timer for OMAP24xx devices is the 32k-sync timer and not the GP timer
and so should not have any impact. This should be re-visited for future
devices if this errata is fixed.
Confirmed with Vaibhav Hiremath that this bug also impacts AM33xx
devices.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
2012-09-28 01:47:43 +08:00
|
|
|
OMAP_TIMER_NONPOSTED);
|
2007-11-13 15:24:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct clocksource clocksource_gpt = {
|
|
|
|
.rating = 300,
|
|
|
|
.read = clocksource_read_cycles,
|
|
|
|
.mask = CLOCKSOURCE_MASK(32),
|
|
|
|
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
|
|
|
|
};
|
|
|
|
|
2013-11-16 07:26:18 +08:00
|
|
|
static u64 notrace dmtimer_read_sched_clock(void)
|
2011-02-23 10:59:49 +08:00
|
|
|
{
|
2011-03-30 06:54:49 +08:00
|
|
|
if (clksrc.reserved)
|
2012-09-28 00:49:45 +08:00
|
|
|
return __omap_dm_timer_read_counter(&clksrc,
|
ARM: OMAP3+: Implement timer workaround for errata i103 and i767
Errata Titles:
i103: Delay needed to read some GP timer, WD timer and sync timer
registers after wakeup (OMAP3/4)
i767: Delay needed to read some GP timer registers after wakeup (OMAP5)
Description (i103/i767):
If a General Purpose Timer (GPTimer) is in posted mode
(TSICR [2].POSTED=1), due to internal resynchronizations, values read in
TCRR, TCAR1 and TCAR2 registers right after the timer interface clock
(L4) goes from stopped to active may not return the expected values. The
most common event leading to this situation occurs upon wake up from
idle.
GPTimer non-posted synchronization mode is not impacted by this
limitation.
Workarounds:
1). Disable posted mode
2). Use static dependency between timer clock domain and MPUSS clock
domain
3). Use no-idle mode when the timer is active
Workarounds #2 and #3 are not pratical from a power standpoint and so
workaround #1 has been implemented. Disabling posted mode adds some CPU
overhead for configuring and reading the timers as the CPU has to wait
for accesses to be re-synchronised within the timer. However, disabling
posted mode guarantees correct operation.
Please note that it is safe to use posted mode for timers if the counter
(TCRR) and capture (TCARx) registers will never be read. An example of
this is the clock-event system timer. This is used by the kernel to
schedule events however, the timers counter is never read and capture
registers are not used. Given that the kernel configures this timer
often yet never reads the counter register it is safe to enable posted
mode in this case. Hence, for the timer used for kernel clock-events,
posted mode is enabled by overriding the errata for devices that are
impacted by this defect.
For drivers using the timers that do not read the counter or capture
registers and wish to use posted mode, can override the errata and
enable posted mode by making the following function calls.
__omap_dm_timer_override_errata(timer, OMAP_TIMER_ERRATA_I103_I767);
__omap_dm_timer_enable_posted(timer);
Both dmtimers and watchdogs are impacted by this defect this patch only
implements the workaround for the dmtimer. Currently the watchdog driver
does not read the counter register and so no workaround is necessary.
Posted mode will be disabled for all OMAP2+ devices (including AM33xx)
using a GP timer as a clock-source timer to guarantee correct operation.
This is not necessary for OMAP24xx devices but the default clock-source
timer for OMAP24xx devices is the 32k-sync timer and not the GP timer
and so should not have any impact. This should be re-visited for future
devices if this errata is fixed.
Confirmed with Vaibhav Hiremath that this bug also impacts AM33xx
devices.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
2012-09-28 01:47:43 +08:00
|
|
|
OMAP_TIMER_NONPOSTED);
|
2007-11-13 15:24:02 +08:00
|
|
|
|
2011-12-15 19:19:23 +08:00
|
|
|
return 0;
|
2011-03-30 06:54:49 +08:00
|
|
|
}
|
|
|
|
|
2014-09-10 16:26:17 +08:00
|
|
|
static const struct of_device_id omap_counter_match[] __initconst = {
|
2012-11-16 03:09:03 +08:00
|
|
|
{ .compatible = "ti,omap-counter32k", },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2011-03-30 06:54:49 +08:00
|
|
|
/* Setup free-running counter for clocksource */
|
2012-11-28 05:24:12 +08:00
|
|
|
static int __init __maybe_unused omap2_sync32k_clocksource_init(void)
|
ARM: OMAP: Make OMAP clocksource source selection using kernel param
Current OMAP code supports couple of clocksource options based
on compilation flag (CONFIG_OMAP_32K_TIMER). The 32KHz sync-timer
and a gptimer which can run on 32KHz or system clock (e.g 38.4 MHz).
So there can be 3 options -
1. 32KHz sync-timer
2. Sys_clock based (e.g 13/19.2/26/38.4 MHz) gptimer
3. 32KHz based gptimer.
The optional gptimer based clocksource was added so that it can
give the high precision than sync-timer, so expected usage was 2
and not 3.
Unfortunately option 2, clocksource doesn't meet the requirement of
free-running clock as per clocksource need. It stops in low power states
when sys_clock is cut. That makes gptimer based clocksource option
useless for OMAP2/3/4 devices with sys_clock as a clock input.
So, in order to use option 2, deeper idle state MUST be disabled.
Option 3 will still work but it is no better than 32K sync-timer
based clocksource.
We must support both sync timer and gptimer based clocksource as
some OMAP based derivative SoCs like AM33XX does not have the
sync timer.
Considering above, make sync-timer and gptimer clocksource runtime
selectable so that both OMAP and AMXXXX continue to use the same code.
And, in order to precisely configure/setup sched_clock for given
clocksource, decision has to be made early enough in boot sequence.
So, the solution is,
Use standard kernel parameter ("clocksource=") to override
default 32k_sync-timer, in addition to this, we also use hwmod database
lookup mechanism, through which at run-time we can identify availability
of 32k-sync timer on the device, else fall back to gptimer.
Also, moved low-level SoC specific init code to respective files,
(mach-omap1/timer32k.c and mach-omap2/timer.c)
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Acked-by: Kevin Hilman <khilman@ti.com>
Tested-by: Kevin Hilman <khilman@ti.com>
Cc: Benoit Cousson <b-cousson@ti.com>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Tarun Kanti DebBarma <tarun.kanti@ti.com>
Cc: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
2012-05-10 01:07:05 +08:00
|
|
|
{
|
|
|
|
int ret;
|
2012-10-10 03:12:26 +08:00
|
|
|
struct device_node *np = NULL;
|
ARM: OMAP: Make OMAP clocksource source selection using kernel param
Current OMAP code supports couple of clocksource options based
on compilation flag (CONFIG_OMAP_32K_TIMER). The 32KHz sync-timer
and a gptimer which can run on 32KHz or system clock (e.g 38.4 MHz).
So there can be 3 options -
1. 32KHz sync-timer
2. Sys_clock based (e.g 13/19.2/26/38.4 MHz) gptimer
3. 32KHz based gptimer.
The optional gptimer based clocksource was added so that it can
give the high precision than sync-timer, so expected usage was 2
and not 3.
Unfortunately option 2, clocksource doesn't meet the requirement of
free-running clock as per clocksource need. It stops in low power states
when sys_clock is cut. That makes gptimer based clocksource option
useless for OMAP2/3/4 devices with sys_clock as a clock input.
So, in order to use option 2, deeper idle state MUST be disabled.
Option 3 will still work but it is no better than 32K sync-timer
based clocksource.
We must support both sync timer and gptimer based clocksource as
some OMAP based derivative SoCs like AM33XX does not have the
sync timer.
Considering above, make sync-timer and gptimer clocksource runtime
selectable so that both OMAP and AMXXXX continue to use the same code.
And, in order to precisely configure/setup sched_clock for given
clocksource, decision has to be made early enough in boot sequence.
So, the solution is,
Use standard kernel parameter ("clocksource=") to override
default 32k_sync-timer, in addition to this, we also use hwmod database
lookup mechanism, through which at run-time we can identify availability
of 32k-sync timer on the device, else fall back to gptimer.
Also, moved low-level SoC specific init code to respective files,
(mach-omap1/timer32k.c and mach-omap2/timer.c)
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Acked-by: Kevin Hilman <khilman@ti.com>
Tested-by: Kevin Hilman <khilman@ti.com>
Cc: Benoit Cousson <b-cousson@ti.com>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Tarun Kanti DebBarma <tarun.kanti@ti.com>
Cc: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
2012-05-10 01:07:05 +08:00
|
|
|
struct omap_hwmod *oh;
|
|
|
|
const char *oh_name = "counter_32k";
|
|
|
|
|
2012-10-10 03:12:26 +08:00
|
|
|
/*
|
2017-06-01 06:51:30 +08:00
|
|
|
* See if the 32kHz counter is supported.
|
2012-10-10 03:12:26 +08:00
|
|
|
*/
|
2017-06-01 06:51:30 +08:00
|
|
|
np = omap_get_timer_dt(omap_counter_match, NULL);
|
|
|
|
if (!np)
|
|
|
|
return -ENODEV;
|
|
|
|
|
2018-04-17 01:21:39 +08:00
|
|
|
of_property_read_string_index(np->parent, "ti,hwmods", 0, &oh_name);
|
|
|
|
if (!oh_name) {
|
|
|
|
of_property_read_string_index(np, "ti,hwmods", 0, &oh_name);
|
|
|
|
if (!oh_name)
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
2012-10-10 03:12:26 +08:00
|
|
|
|
ARM: OMAP: Make OMAP clocksource source selection using kernel param
Current OMAP code supports couple of clocksource options based
on compilation flag (CONFIG_OMAP_32K_TIMER). The 32KHz sync-timer
and a gptimer which can run on 32KHz or system clock (e.g 38.4 MHz).
So there can be 3 options -
1. 32KHz sync-timer
2. Sys_clock based (e.g 13/19.2/26/38.4 MHz) gptimer
3. 32KHz based gptimer.
The optional gptimer based clocksource was added so that it can
give the high precision than sync-timer, so expected usage was 2
and not 3.
Unfortunately option 2, clocksource doesn't meet the requirement of
free-running clock as per clocksource need. It stops in low power states
when sys_clock is cut. That makes gptimer based clocksource option
useless for OMAP2/3/4 devices with sys_clock as a clock input.
So, in order to use option 2, deeper idle state MUST be disabled.
Option 3 will still work but it is no better than 32K sync-timer
based clocksource.
We must support both sync timer and gptimer based clocksource as
some OMAP based derivative SoCs like AM33XX does not have the
sync timer.
Considering above, make sync-timer and gptimer clocksource runtime
selectable so that both OMAP and AMXXXX continue to use the same code.
And, in order to precisely configure/setup sched_clock for given
clocksource, decision has to be made early enough in boot sequence.
So, the solution is,
Use standard kernel parameter ("clocksource=") to override
default 32k_sync-timer, in addition to this, we also use hwmod database
lookup mechanism, through which at run-time we can identify availability
of 32k-sync timer on the device, else fall back to gptimer.
Also, moved low-level SoC specific init code to respective files,
(mach-omap1/timer32k.c and mach-omap2/timer.c)
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Acked-by: Kevin Hilman <khilman@ti.com>
Tested-by: Kevin Hilman <khilman@ti.com>
Cc: Benoit Cousson <b-cousson@ti.com>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Tarun Kanti DebBarma <tarun.kanti@ti.com>
Cc: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
2012-05-10 01:07:05 +08:00
|
|
|
/*
|
|
|
|
* First check hwmod data is available for sync32k counter
|
|
|
|
*/
|
|
|
|
oh = omap_hwmod_lookup(oh_name);
|
|
|
|
if (!oh || oh->slaves_cnt == 0)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
omap_hwmod_setup_one(oh_name);
|
|
|
|
|
|
|
|
ret = omap_hwmod_enable(oh);
|
|
|
|
if (ret) {
|
|
|
|
pr_warn("%s: failed to enable counter_32k module (%d)\n",
|
|
|
|
__func__, ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-05-23 02:22:20 +08:00
|
|
|
static unsigned int omap2_gptimer_clksrc_load;
|
|
|
|
|
|
|
|
static void omap2_gptimer_clksrc_suspend(struct clocksource *unused)
|
|
|
|
{
|
|
|
|
omap2_gptimer_clksrc_load =
|
|
|
|
__omap_dm_timer_read_counter(&clksrc, OMAP_TIMER_NONPOSTED);
|
|
|
|
|
|
|
|
omap_hwmod_idle(clocksource_gpt_hwmod);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void omap2_gptimer_clksrc_resume(struct clocksource *unused)
|
|
|
|
{
|
|
|
|
omap_hwmod_enable(clocksource_gpt_hwmod);
|
|
|
|
|
|
|
|
__omap_dm_timer_load_start(&clksrc,
|
|
|
|
OMAP_TIMER_CTRL_ST | OMAP_TIMER_CTRL_AR,
|
|
|
|
omap2_gptimer_clksrc_load,
|
|
|
|
OMAP_TIMER_NONPOSTED);
|
|
|
|
}
|
|
|
|
|
ARM: OMAP: Make OMAP clocksource source selection using kernel param
Current OMAP code supports couple of clocksource options based
on compilation flag (CONFIG_OMAP_32K_TIMER). The 32KHz sync-timer
and a gptimer which can run on 32KHz or system clock (e.g 38.4 MHz).
So there can be 3 options -
1. 32KHz sync-timer
2. Sys_clock based (e.g 13/19.2/26/38.4 MHz) gptimer
3. 32KHz based gptimer.
The optional gptimer based clocksource was added so that it can
give the high precision than sync-timer, so expected usage was 2
and not 3.
Unfortunately option 2, clocksource doesn't meet the requirement of
free-running clock as per clocksource need. It stops in low power states
when sys_clock is cut. That makes gptimer based clocksource option
useless for OMAP2/3/4 devices with sys_clock as a clock input.
So, in order to use option 2, deeper idle state MUST be disabled.
Option 3 will still work but it is no better than 32K sync-timer
based clocksource.
We must support both sync timer and gptimer based clocksource as
some OMAP based derivative SoCs like AM33XX does not have the
sync timer.
Considering above, make sync-timer and gptimer clocksource runtime
selectable so that both OMAP and AMXXXX continue to use the same code.
And, in order to precisely configure/setup sched_clock for given
clocksource, decision has to be made early enough in boot sequence.
So, the solution is,
Use standard kernel parameter ("clocksource=") to override
default 32k_sync-timer, in addition to this, we also use hwmod database
lookup mechanism, through which at run-time we can identify availability
of 32k-sync timer on the device, else fall back to gptimer.
Also, moved low-level SoC specific init code to respective files,
(mach-omap1/timer32k.c and mach-omap2/timer.c)
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Acked-by: Kevin Hilman <khilman@ti.com>
Tested-by: Kevin Hilman <khilman@ti.com>
Cc: Benoit Cousson <b-cousson@ti.com>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Tarun Kanti DebBarma <tarun.kanti@ti.com>
Cc: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
2012-05-10 01:07:05 +08:00
|
|
|
static void __init omap2_gptimer_clocksource_init(int gptimer_id,
|
ARM: OMAP3: Update clocksource timer selection
When booting with device-tree for OMAP3 and AM335x devices and a gptimer
is used as the clocksource (which is always the case for AM335x), a
gptimer located in a power domain that is not always-on is selected.
Ideally we should use a gptimer for clocksource that is located in a
power domain that is always on (such as the wake-up domain) so that time
can be maintained during a kernel suspend without keeping on additional
power domains unnecessarily.
In order to fix this so that we can select a gptimer located in a power
domain that is always-on, the following changes were made ...
1. Currently, only when selecting a gptimer to use for a clockevent
timer, do we pass a timer property that can be used to select a
specific gptimer. Change this so that we can pass a property when
selecting a gptimer to use for a clocksource timer too.
2. Currently, when selecting either a gptimer to use for a clockevent
timer or a clocksource timer and no timer property is passed, then
the first available timer is selected regardless of the properties
it has. Change this so that if no properties are passed, then a timer
that does not have additional features (such as always-on, dsp-irq,
pwm, and secure) is selected.
For OMAP3 and AM335x devices that use a gptimer for clocksource, change
the selection of the gptimer so that by default the gptimer located in
the always-on power domain is used for clocksource instead of
clockevents.
Please note that using a gptimer for both clocksource and clockevents
can have a system power impact during idle. The reason being is that
OMAP and AMxxx devices typically only have one gptimer in a power domain
that is always-on. Therefore when the kernel is idle both the clocksource
and clockevent timers will be active and this will keep additional power
domains on. During kernel suspend, only the clocksource timer is active
and therefore, it is better to use a gptimer in a power domain that is
always-on for clocksource.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Acked-by: Igor Grinberg <grinberg@compulab.co.il>
2013-01-29 07:53:57 +08:00
|
|
|
const char *fck_source,
|
|
|
|
const char *property)
|
2011-03-30 06:54:49 +08:00
|
|
|
{
|
|
|
|
int res;
|
|
|
|
|
2013-02-02 06:40:09 +08:00
|
|
|
clksrc.id = gptimer_id;
|
ARM: OMAP3+: Implement timer workaround for errata i103 and i767
Errata Titles:
i103: Delay needed to read some GP timer, WD timer and sync timer
registers after wakeup (OMAP3/4)
i767: Delay needed to read some GP timer registers after wakeup (OMAP5)
Description (i103/i767):
If a General Purpose Timer (GPTimer) is in posted mode
(TSICR [2].POSTED=1), due to internal resynchronizations, values read in
TCRR, TCAR1 and TCAR2 registers right after the timer interface clock
(L4) goes from stopped to active may not return the expected values. The
most common event leading to this situation occurs upon wake up from
idle.
GPTimer non-posted synchronization mode is not impacted by this
limitation.
Workarounds:
1). Disable posted mode
2). Use static dependency between timer clock domain and MPUSS clock
domain
3). Use no-idle mode when the timer is active
Workarounds #2 and #3 are not pratical from a power standpoint and so
workaround #1 has been implemented. Disabling posted mode adds some CPU
overhead for configuring and reading the timers as the CPU has to wait
for accesses to be re-synchronised within the timer. However, disabling
posted mode guarantees correct operation.
Please note that it is safe to use posted mode for timers if the counter
(TCRR) and capture (TCARx) registers will never be read. An example of
this is the clock-event system timer. This is used by the kernel to
schedule events however, the timers counter is never read and capture
registers are not used. Given that the kernel configures this timer
often yet never reads the counter register it is safe to enable posted
mode in this case. Hence, for the timer used for kernel clock-events,
posted mode is enabled by overriding the errata for devices that are
impacted by this defect.
For drivers using the timers that do not read the counter or capture
registers and wish to use posted mode, can override the errata and
enable posted mode by making the following function calls.
__omap_dm_timer_override_errata(timer, OMAP_TIMER_ERRATA_I103_I767);
__omap_dm_timer_enable_posted(timer);
Both dmtimers and watchdogs are impacted by this defect this patch only
implements the workaround for the dmtimer. Currently the watchdog driver
does not read the counter register and so no workaround is necessary.
Posted mode will be disabled for all OMAP2+ devices (including AM33xx)
using a GP timer as a clock-source timer to guarantee correct operation.
This is not necessary for OMAP24xx devices but the default clock-source
timer for OMAP24xx devices is the 32k-sync timer and not the GP timer
and so should not have any impact. This should be re-visited for future
devices if this errata is fixed.
Confirmed with Vaibhav Hiremath that this bug also impacts AM33xx
devices.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
2012-09-28 01:47:43 +08:00
|
|
|
clksrc.errata = omap_dm_timer_get_errata();
|
|
|
|
|
2013-02-02 06:40:09 +08:00
|
|
|
res = omap_dm_timer_init_one(&clksrc, fck_source, property,
|
2013-01-30 03:55:25 +08:00
|
|
|
&clocksource_gpt.name,
|
ARM: OMAP3+: Implement timer workaround for errata i103 and i767
Errata Titles:
i103: Delay needed to read some GP timer, WD timer and sync timer
registers after wakeup (OMAP3/4)
i767: Delay needed to read some GP timer registers after wakeup (OMAP5)
Description (i103/i767):
If a General Purpose Timer (GPTimer) is in posted mode
(TSICR [2].POSTED=1), due to internal resynchronizations, values read in
TCRR, TCAR1 and TCAR2 registers right after the timer interface clock
(L4) goes from stopped to active may not return the expected values. The
most common event leading to this situation occurs upon wake up from
idle.
GPTimer non-posted synchronization mode is not impacted by this
limitation.
Workarounds:
1). Disable posted mode
2). Use static dependency between timer clock domain and MPUSS clock
domain
3). Use no-idle mode when the timer is active
Workarounds #2 and #3 are not pratical from a power standpoint and so
workaround #1 has been implemented. Disabling posted mode adds some CPU
overhead for configuring and reading the timers as the CPU has to wait
for accesses to be re-synchronised within the timer. However, disabling
posted mode guarantees correct operation.
Please note that it is safe to use posted mode for timers if the counter
(TCRR) and capture (TCARx) registers will never be read. An example of
this is the clock-event system timer. This is used by the kernel to
schedule events however, the timers counter is never read and capture
registers are not used. Given that the kernel configures this timer
often yet never reads the counter register it is safe to enable posted
mode in this case. Hence, for the timer used for kernel clock-events,
posted mode is enabled by overriding the errata for devices that are
impacted by this defect.
For drivers using the timers that do not read the counter or capture
registers and wish to use posted mode, can override the errata and
enable posted mode by making the following function calls.
__omap_dm_timer_override_errata(timer, OMAP_TIMER_ERRATA_I103_I767);
__omap_dm_timer_enable_posted(timer);
Both dmtimers and watchdogs are impacted by this defect this patch only
implements the workaround for the dmtimer. Currently the watchdog driver
does not read the counter register and so no workaround is necessary.
Posted mode will be disabled for all OMAP2+ devices (including AM33xx)
using a GP timer as a clock-source timer to guarantee correct operation.
This is not necessary for OMAP24xx devices but the default clock-source
timer for OMAP24xx devices is the 32k-sync timer and not the GP timer
and so should not have any impact. This should be re-visited for future
devices if this errata is fixed.
Confirmed with Vaibhav Hiremath that this bug also impacts AM33xx
devices.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
2012-09-28 01:47:43 +08:00
|
|
|
OMAP_TIMER_NONPOSTED);
|
2018-05-23 02:22:20 +08:00
|
|
|
|
|
|
|
if (soc_is_am43xx()) {
|
|
|
|
clocksource_gpt.suspend = omap2_gptimer_clksrc_suspend;
|
|
|
|
clocksource_gpt.resume = omap2_gptimer_clksrc_resume;
|
|
|
|
|
|
|
|
clocksource_gpt_hwmod =
|
|
|
|
omap_hwmod_lookup(clocksource_gpt.name);
|
|
|
|
}
|
|
|
|
|
2011-03-30 06:54:49 +08:00
|
|
|
BUG_ON(res);
|
2007-11-13 15:24:02 +08:00
|
|
|
|
2011-09-17 06:44:20 +08:00
|
|
|
__omap_dm_timer_load_start(&clksrc,
|
2012-09-28 00:49:45 +08:00
|
|
|
OMAP_TIMER_CTRL_ST | OMAP_TIMER_CTRL_AR, 0,
|
ARM: OMAP3+: Implement timer workaround for errata i103 and i767
Errata Titles:
i103: Delay needed to read some GP timer, WD timer and sync timer
registers after wakeup (OMAP3/4)
i767: Delay needed to read some GP timer registers after wakeup (OMAP5)
Description (i103/i767):
If a General Purpose Timer (GPTimer) is in posted mode
(TSICR [2].POSTED=1), due to internal resynchronizations, values read in
TCRR, TCAR1 and TCAR2 registers right after the timer interface clock
(L4) goes from stopped to active may not return the expected values. The
most common event leading to this situation occurs upon wake up from
idle.
GPTimer non-posted synchronization mode is not impacted by this
limitation.
Workarounds:
1). Disable posted mode
2). Use static dependency between timer clock domain and MPUSS clock
domain
3). Use no-idle mode when the timer is active
Workarounds #2 and #3 are not pratical from a power standpoint and so
workaround #1 has been implemented. Disabling posted mode adds some CPU
overhead for configuring and reading the timers as the CPU has to wait
for accesses to be re-synchronised within the timer. However, disabling
posted mode guarantees correct operation.
Please note that it is safe to use posted mode for timers if the counter
(TCRR) and capture (TCARx) registers will never be read. An example of
this is the clock-event system timer. This is used by the kernel to
schedule events however, the timers counter is never read and capture
registers are not used. Given that the kernel configures this timer
often yet never reads the counter register it is safe to enable posted
mode in this case. Hence, for the timer used for kernel clock-events,
posted mode is enabled by overriding the errata for devices that are
impacted by this defect.
For drivers using the timers that do not read the counter or capture
registers and wish to use posted mode, can override the errata and
enable posted mode by making the following function calls.
__omap_dm_timer_override_errata(timer, OMAP_TIMER_ERRATA_I103_I767);
__omap_dm_timer_enable_posted(timer);
Both dmtimers and watchdogs are impacted by this defect this patch only
implements the workaround for the dmtimer. Currently the watchdog driver
does not read the counter register and so no workaround is necessary.
Posted mode will be disabled for all OMAP2+ devices (including AM33xx)
using a GP timer as a clock-source timer to guarantee correct operation.
This is not necessary for OMAP24xx devices but the default clock-source
timer for OMAP24xx devices is the 32k-sync timer and not the GP timer
and so should not have any impact. This should be re-visited for future
devices if this errata is fixed.
Confirmed with Vaibhav Hiremath that this bug also impacts AM33xx
devices.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
2012-09-28 01:47:43 +08:00
|
|
|
OMAP_TIMER_NONPOSTED);
|
2013-11-16 07:26:18 +08:00
|
|
|
sched_clock_register(dmtimer_read_sched_clock, 32, clksrc.rate);
|
2011-02-23 10:59:49 +08:00
|
|
|
|
2011-03-30 06:54:49 +08:00
|
|
|
if (clocksource_register_hz(&clocksource_gpt, clksrc.rate))
|
|
|
|
pr_err("Could not register clocksource %s\n",
|
|
|
|
clocksource_gpt.name);
|
ARM: OMAP: Make OMAP clocksource source selection using kernel param
Current OMAP code supports couple of clocksource options based
on compilation flag (CONFIG_OMAP_32K_TIMER). The 32KHz sync-timer
and a gptimer which can run on 32KHz or system clock (e.g 38.4 MHz).
So there can be 3 options -
1. 32KHz sync-timer
2. Sys_clock based (e.g 13/19.2/26/38.4 MHz) gptimer
3. 32KHz based gptimer.
The optional gptimer based clocksource was added so that it can
give the high precision than sync-timer, so expected usage was 2
and not 3.
Unfortunately option 2, clocksource doesn't meet the requirement of
free-running clock as per clocksource need. It stops in low power states
when sys_clock is cut. That makes gptimer based clocksource option
useless for OMAP2/3/4 devices with sys_clock as a clock input.
So, in order to use option 2, deeper idle state MUST be disabled.
Option 3 will still work but it is no better than 32K sync-timer
based clocksource.
We must support both sync timer and gptimer based clocksource as
some OMAP based derivative SoCs like AM33XX does not have the
sync timer.
Considering above, make sync-timer and gptimer clocksource runtime
selectable so that both OMAP and AMXXXX continue to use the same code.
And, in order to precisely configure/setup sched_clock for given
clocksource, decision has to be made early enough in boot sequence.
So, the solution is,
Use standard kernel parameter ("clocksource=") to override
default 32k_sync-timer, in addition to this, we also use hwmod database
lookup mechanism, through which at run-time we can identify availability
of 32k-sync timer on the device, else fall back to gptimer.
Also, moved low-level SoC specific init code to respective files,
(mach-omap1/timer32k.c and mach-omap2/timer.c)
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Acked-by: Kevin Hilman <khilman@ti.com>
Tested-by: Kevin Hilman <khilman@ti.com>
Cc: Benoit Cousson <b-cousson@ti.com>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Tarun Kanti DebBarma <tarun.kanti@ti.com>
Cc: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
2012-05-10 01:07:05 +08:00
|
|
|
else
|
2013-01-30 03:55:25 +08:00
|
|
|
pr_info("OMAP clocksource: %s at %lu Hz\n",
|
|
|
|
clocksource_gpt.name, clksrc.rate);
|
ARM: OMAP: Make OMAP clocksource source selection using kernel param
Current OMAP code supports couple of clocksource options based
on compilation flag (CONFIG_OMAP_32K_TIMER). The 32KHz sync-timer
and a gptimer which can run on 32KHz or system clock (e.g 38.4 MHz).
So there can be 3 options -
1. 32KHz sync-timer
2. Sys_clock based (e.g 13/19.2/26/38.4 MHz) gptimer
3. 32KHz based gptimer.
The optional gptimer based clocksource was added so that it can
give the high precision than sync-timer, so expected usage was 2
and not 3.
Unfortunately option 2, clocksource doesn't meet the requirement of
free-running clock as per clocksource need. It stops in low power states
when sys_clock is cut. That makes gptimer based clocksource option
useless for OMAP2/3/4 devices with sys_clock as a clock input.
So, in order to use option 2, deeper idle state MUST be disabled.
Option 3 will still work but it is no better than 32K sync-timer
based clocksource.
We must support both sync timer and gptimer based clocksource as
some OMAP based derivative SoCs like AM33XX does not have the
sync timer.
Considering above, make sync-timer and gptimer clocksource runtime
selectable so that both OMAP and AMXXXX continue to use the same code.
And, in order to precisely configure/setup sched_clock for given
clocksource, decision has to be made early enough in boot sequence.
So, the solution is,
Use standard kernel parameter ("clocksource=") to override
default 32k_sync-timer, in addition to this, we also use hwmod database
lookup mechanism, through which at run-time we can identify availability
of 32k-sync timer on the device, else fall back to gptimer.
Also, moved low-level SoC specific init code to respective files,
(mach-omap1/timer32k.c and mach-omap2/timer.c)
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Acked-by: Kevin Hilman <khilman@ti.com>
Tested-by: Kevin Hilman <khilman@ti.com>
Cc: Benoit Cousson <b-cousson@ti.com>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Tarun Kanti DebBarma <tarun.kanti@ti.com>
Cc: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
2012-05-10 01:07:05 +08:00
|
|
|
}
|
|
|
|
|
2015-09-30 02:12:55 +08:00
|
|
|
static void __init __omap_sync32k_timer_init(int clkev_nr, const char *clkev_src,
|
|
|
|
const char *clkev_prop, int clksrc_nr, const char *clksrc_src,
|
|
|
|
const char *clksrc_prop, bool gptimer)
|
|
|
|
{
|
|
|
|
omap_clk_init();
|
|
|
|
omap_dmtimer_init();
|
2024-06-12 13:13:20 +08:00
|
|
|
dmtimer_clkevt_init_common(&clockevent, clkev_nr, clkev_src,
|
|
|
|
CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
|
|
|
|
cpu_possible_mask, clkev_prop, 300, "clockevent");
|
|
|
|
clockevents_config_and_register(&clockevent.dev, clockevent.timer.rate,
|
|
|
|
3, /* Timer internal resynch latency */
|
|
|
|
0xffffffff);
|
|
|
|
|
|
|
|
if (soc_is_dra7xx())
|
|
|
|
dmtimer_percpu_quirk_init();
|
2015-09-30 02:12:55 +08:00
|
|
|
|
|
|
|
/* Enable the use of clocksource="gp_timer" kernel parameter */
|
|
|
|
if (use_gptimer_clksrc || gptimer)
|
|
|
|
omap2_gptimer_clocksource_init(clksrc_nr, clksrc_src,
|
|
|
|
clksrc_prop);
|
|
|
|
else
|
|
|
|
omap2_sync32k_clocksource_init();
|
|
|
|
}
|
|
|
|
|
2015-09-30 02:26:45 +08:00
|
|
|
void __init omap_init_time(void)
|
2015-09-30 02:12:55 +08:00
|
|
|
{
|
|
|
|
__omap_sync32k_timer_init(1, "timer_32k_ck", "ti,timer-alwon",
|
|
|
|
2, "timer_sys_ck", NULL, false);
|
2015-09-30 02:15:02 +08:00
|
|
|
|
2017-05-26 23:40:46 +08:00
|
|
|
timer_probe();
|
2015-09-30 02:12:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_SOC_AM43XX)
|
|
|
|
void __init omap3_secure_sync32k_timer_init(void)
|
|
|
|
{
|
|
|
|
__omap_sync32k_timer_init(12, "secure_32k_fck", "ti,timer-secure",
|
|
|
|
2, "timer_sys_ck", NULL, false);
|
2016-06-16 20:25:18 +08:00
|
|
|
|
2017-05-26 23:40:46 +08:00
|
|
|
timer_probe();
|
2015-09-30 02:12:55 +08:00
|
|
|
}
|
|
|
|
#endif /* CONFIG_ARCH_OMAP3 */
|
|
|
|
|
2016-12-05 11:57:44 +08:00
|
|
|
#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_SOC_AM33XX) || \
|
2024-06-12 13:13:20 +08:00
|
|
|
defined(CONFIG_SOC_AM43XX) || defined(CONFIG_SOC_DRA7XX)
|
2015-09-30 02:12:55 +08:00
|
|
|
void __init omap3_gptimer_timer_init(void)
|
|
|
|
{
|
|
|
|
__omap_sync32k_timer_init(2, "timer_sys_ck", NULL,
|
|
|
|
1, "timer_sys_ck", "ti,timer-alwon", true);
|
2016-12-05 11:57:44 +08:00
|
|
|
if (of_have_populated_dt())
|
2017-05-26 23:40:46 +08:00
|
|
|
timer_probe();
|
2015-09-30 02:12:55 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
|
2016-12-05 11:57:44 +08:00
|
|
|
defined(CONFIG_SOC_DRA7XX)
|
2015-09-30 02:12:55 +08:00
|
|
|
static void __init omap4_sync32k_timer_init(void)
|
|
|
|
{
|
|
|
|
__omap_sync32k_timer_init(1, "timer_32k_ck", "ti,timer-alwon",
|
|
|
|
2, "sys_clkin_ck", NULL, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void __init omap4_local_timer_init(void)
|
|
|
|
{
|
|
|
|
omap4_sync32k_timer_init();
|
2017-05-26 23:40:46 +08:00
|
|
|
timer_probe();
|
2015-09-30 02:12:55 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_SOC_OMAP5) || defined(CONFIG_SOC_DRA7XX)
|
|
|
|
|
2012-08-13 16:54:24 +08:00
|
|
|
/*
|
|
|
|
* 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)
|
|
|
|
{
|
2015-09-30 02:12:55 +08:00
|
|
|
#ifdef CONFIG_SOC_HAS_REALTIME_COUNTER
|
2012-08-13 16:54:24 +08:00
|
|
|
void __iomem *base;
|
|
|
|
static struct clk *sys_clk;
|
|
|
|
unsigned long rate;
|
2015-01-06 07:45:45 +08:00
|
|
|
unsigned int reg;
|
|
|
|
unsigned long long num, den;
|
2012-08-13 16:54:24 +08:00
|
|
|
|
|
|
|
base = ioremap(REALTIME_COUNTER_BASE, SZ_32);
|
|
|
|
if (!base) {
|
|
|
|
pr_err("%s: ioremap failed\n", __func__);
|
|
|
|
return;
|
|
|
|
}
|
2013-04-04 01:47:59 +08:00
|
|
|
sys_clk = clk_get(NULL, "sys_clkin");
|
2012-10-09 06:01:41 +08:00
|
|
|
if (IS_ERR(sys_clk)) {
|
2012-08-13 16:54:24 +08:00
|
|
|
pr_err("%s: failed to get system clock handle\n", __func__);
|
|
|
|
iounmap(base);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rate = clk_get_rate(sys_clk);
|
2024-06-12 13:13:20 +08:00
|
|
|
clk_put(sys_clk);
|
2015-01-06 07:45:45 +08:00
|
|
|
|
|
|
|
if (soc_is_dra7xx()) {
|
|
|
|
/*
|
|
|
|
* Errata i856 says the 32.768KHz crystal does not start at
|
|
|
|
* power on, so the CPU falls back to an emulated 32KHz clock
|
|
|
|
* based on sysclk / 610 instead. This causes the master counter
|
|
|
|
* frequency to not be 6.144MHz but at sysclk / 610 * 375 / 2
|
|
|
|
* (OR sysclk * 75 / 244)
|
|
|
|
*
|
|
|
|
* This affects at least the DRA7/AM572x 1.0, 1.1 revisions.
|
|
|
|
* Of course any board built without a populated 32.768KHz
|
|
|
|
* crystal would also need this fix even if the CPU is fixed
|
|
|
|
* later.
|
|
|
|
*
|
|
|
|
* Either case can be detected by using the two speedselect bits
|
|
|
|
* If they are not 0, then the 32.768KHz clock driving the
|
|
|
|
* coarse counter that corrects the fine counter every time it
|
|
|
|
* ticks is actually rate/610 rather than 32.768KHz and we
|
|
|
|
* should compensate to avoid the 570ppm (at 20MHz, much worse
|
|
|
|
* at other rates) too fast system time.
|
|
|
|
*/
|
|
|
|
reg = omap_ctrl_readl(DRA7_CTRL_CORE_BOOTSTRAP);
|
|
|
|
if (reg & DRA7_SPEEDSELECT_MASK) {
|
|
|
|
num = 75;
|
|
|
|
den = 244;
|
|
|
|
goto sysclk1_based;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-13 16:54:24 +08:00
|
|
|
/* Numerator/denumerator values refer TRM Realtime Counter section */
|
|
|
|
switch (rate) {
|
2015-01-06 07:45:45 +08:00
|
|
|
case 12000000:
|
2012-08-13 16:54:24 +08:00
|
|
|
num = 64;
|
|
|
|
den = 125;
|
|
|
|
break;
|
2015-01-06 07:45:45 +08:00
|
|
|
case 13000000:
|
2012-08-13 16:54:24 +08:00
|
|
|
num = 768;
|
|
|
|
den = 1625;
|
|
|
|
break;
|
|
|
|
case 19200000:
|
|
|
|
num = 8;
|
|
|
|
den = 25;
|
|
|
|
break;
|
2013-09-18 19:20:11 +08:00
|
|
|
case 20000000:
|
|
|
|
num = 192;
|
|
|
|
den = 625;
|
|
|
|
break;
|
2015-01-06 07:45:45 +08:00
|
|
|
case 26000000:
|
2012-08-13 16:54:24 +08:00
|
|
|
num = 384;
|
|
|
|
den = 1625;
|
|
|
|
break;
|
2015-01-06 07:45:45 +08:00
|
|
|
case 27000000:
|
2012-08-13 16:54:24 +08:00
|
|
|
num = 256;
|
|
|
|
den = 1125;
|
|
|
|
break;
|
|
|
|
case 38400000:
|
|
|
|
default:
|
|
|
|
/* Program it for 38.4 MHz */
|
|
|
|
num = 4;
|
|
|
|
den = 25;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-01-06 07:45:45 +08:00
|
|
|
sysclk1_based:
|
2012-08-13 16:54:24 +08:00
|
|
|
/* Program numerator and denumerator registers */
|
2014-04-16 01:37:46 +08:00
|
|
|
reg = readl_relaxed(base + INCREMENTER_NUMERATOR_OFFSET) &
|
2012-08-13 16:54:24 +08:00
|
|
|
NUMERATOR_DENUMERATOR_MASK;
|
|
|
|
reg |= num;
|
2014-04-16 01:37:46 +08:00
|
|
|
writel_relaxed(reg, base + INCREMENTER_NUMERATOR_OFFSET);
|
2012-08-13 16:54:24 +08:00
|
|
|
|
2014-04-16 01:37:46 +08:00
|
|
|
reg = readl_relaxed(base + INCREMENTER_DENUMERATOR_RELOAD_OFFSET) &
|
2012-08-13 16:54:24 +08:00
|
|
|
NUMERATOR_DENUMERATOR_MASK;
|
|
|
|
reg |= den;
|
2014-04-16 01:37:46 +08:00
|
|
|
writel_relaxed(reg, base + INCREMENTER_DENUMERATOR_RELOAD_OFFSET);
|
2012-08-13 16:54:24 +08:00
|
|
|
|
2015-01-06 07:45:45 +08:00
|
|
|
arch_timer_freq = DIV_ROUND_UP_ULL(rate * num, den);
|
2013-10-10 15:43:48 +08:00
|
|
|
set_cntfreq();
|
|
|
|
|
2012-08-13 16:54:24 +08:00
|
|
|
iounmap(base);
|
|
|
|
#endif
|
2012-11-20 15:17:15 +08:00
|
|
|
}
|
|
|
|
|
2012-11-09 03:40:59 +08:00
|
|
|
void __init omap5_realtime_timer_init(void)
|
2012-08-13 16:54:24 +08:00
|
|
|
{
|
2013-01-12 10:23:09 +08:00
|
|
|
omap4_sync32k_timer_init();
|
2012-08-13 16:54:24 +08:00
|
|
|
realtime_counter_init();
|
2012-08-13 17:09:03 +08:00
|
|
|
|
2017-05-26 23:40:46 +08:00
|
|
|
timer_probe();
|
2012-08-13 16:54:24 +08:00
|
|
|
}
|
2013-10-08 16:50:33 +08:00
|
|
|
#endif /* CONFIG_SOC_OMAP5 || CONFIG_SOC_DRA7XX */
|
2012-05-02 15:37:12 +08:00
|
|
|
|
ARM: OMAP: Make OMAP clocksource source selection using kernel param
Current OMAP code supports couple of clocksource options based
on compilation flag (CONFIG_OMAP_32K_TIMER). The 32KHz sync-timer
and a gptimer which can run on 32KHz or system clock (e.g 38.4 MHz).
So there can be 3 options -
1. 32KHz sync-timer
2. Sys_clock based (e.g 13/19.2/26/38.4 MHz) gptimer
3. 32KHz based gptimer.
The optional gptimer based clocksource was added so that it can
give the high precision than sync-timer, so expected usage was 2
and not 3.
Unfortunately option 2, clocksource doesn't meet the requirement of
free-running clock as per clocksource need. It stops in low power states
when sys_clock is cut. That makes gptimer based clocksource option
useless for OMAP2/3/4 devices with sys_clock as a clock input.
So, in order to use option 2, deeper idle state MUST be disabled.
Option 3 will still work but it is no better than 32K sync-timer
based clocksource.
We must support both sync timer and gptimer based clocksource as
some OMAP based derivative SoCs like AM33XX does not have the
sync timer.
Considering above, make sync-timer and gptimer clocksource runtime
selectable so that both OMAP and AMXXXX continue to use the same code.
And, in order to precisely configure/setup sched_clock for given
clocksource, decision has to be made early enough in boot sequence.
So, the solution is,
Use standard kernel parameter ("clocksource=") to override
default 32k_sync-timer, in addition to this, we also use hwmod database
lookup mechanism, through which at run-time we can identify availability
of 32k-sync timer on the device, else fall back to gptimer.
Also, moved low-level SoC specific init code to respective files,
(mach-omap1/timer32k.c and mach-omap2/timer.c)
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Acked-by: Kevin Hilman <khilman@ti.com>
Tested-by: Kevin Hilman <khilman@ti.com>
Cc: Benoit Cousson <b-cousson@ti.com>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Tarun Kanti DebBarma <tarun.kanti@ti.com>
Cc: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
2012-05-10 01:07:05 +08:00
|
|
|
/**
|
|
|
|
* omap2_override_clocksource - clocksource override with user configuration
|
|
|
|
*
|
|
|
|
* Allows user to override default clocksource, using kernel parameter
|
|
|
|
* clocksource="gp_timer" (For all OMAP2PLUS architectures)
|
|
|
|
*
|
|
|
|
* Note that, here we are using same standard kernel parameter "clocksource=",
|
|
|
|
* and not introducing any OMAP specific interface.
|
|
|
|
*/
|
|
|
|
static int __init omap2_override_clocksource(char *str)
|
|
|
|
{
|
|
|
|
if (!str)
|
|
|
|
return 0;
|
|
|
|
/*
|
|
|
|
* For OMAP architecture, we only have two options
|
|
|
|
* - sync_32k (default)
|
|
|
|
* - gp_timer (sys_clk based)
|
|
|
|
*/
|
|
|
|
if (!strcmp(str, "gp_timer"))
|
|
|
|
use_gptimer_clksrc = true;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
early_param("clocksource", omap2_override_clocksource);
|