Skip to content
Snippets Groups Projects
Commit b15b56a0 authored by leichuan's avatar leichuan Committed by Kenneth Johansson
Browse files

GPTC heartbeat timer for ledc

parent becd5978
No related branches found
No related tags found
No related merge requests found
......@@ -83,6 +83,7 @@ enum gptc_timer_type {
TIMER_TYPE_CLK_SRC,
TIMER_TYPE_CLK_EVT,
TIMER_TYPE_WDT,
TIMER_TYPE_HEARTBEAT,
TIMER_TYPE_MAX,
};
......@@ -117,6 +118,7 @@ struct gptc_timer {
struct list_head clksrc; /* Node in clock source list */
struct list_head clkevt; /* Node in clock event list */
struct list_head wdt; /* Node in watchdog timer */
struct list_head heartbeat; /* Heartbeat */
};
struct gptc_clocksource {
......@@ -135,6 +137,7 @@ static LIST_HEAD(gptc_list);
static LIST_HEAD(gptc_clksrc_list);
static LIST_HEAD(gptc_clkevt_list);
static LIST_HEAD(gptc_wdt_list);
static LIST_HEAD(gptc_heartbeat_list);
unsigned long gptc_phy_base;
static bool gptc_clksrc_init;
......@@ -355,7 +358,8 @@ static void gptc_per_timer_init(struct gptc_timer *timer)
gptc_count_dir(timer);
gptc_enable_32bit_timer(timer);
gptc_reset_counter(timer);
if (timer->type == TIMER_TYPE_CLK_SRC)
if (timer->type == TIMER_TYPE_CLK_SRC ||
timer->type == TIMER_TYPE_HEARTBEAT)
gptc_reload_and_run(timer);
}
......@@ -370,6 +374,8 @@ static const char *const timer_type_to_str(u32 type)
case TIMER_TYPE_WDT:
return "wdt";
case TIMER_TYPE_HEARTBEAT:
return "heartbeat";
default:
return "none";
}
......@@ -545,6 +551,13 @@ static int gptc_of_parse_timer(struct gptc *gptc)
timer->cpuid = 0;
list_add_tail(&timer->clksrc, &gptc_clksrc_list);
break;
case TIMER_TYPE_HEARTBEAT:
INIT_LIST_HEAD(&timer->heartbeat);
timer->irq = 0;
timer->dir = GPTC_COUNT_UP;
timer->cpuid = 0;
list_add_tail(&timer->heartbeat, &gptc_heartbeat_list);
break;
case TIMER_TYPE_CLK_EVT:
case TIMER_TYPE_WDT:
timer->irq = irq_of_parse_and_map(np, timer->tid);
......@@ -850,6 +863,24 @@ static int __init gptc_timer_init(struct device_node *np)
CLOCKSOURCE_OF_DECLARE(lantiq_gptc_timer, "lantiq,gptc", gptc_timer_init);
CLOCKSOURCE_OF_DECLARE(intel_gptc_timer, "intel,gptc", gptc_timer_init);
static int __init gptc_heartbeat_init(void)
{
struct gptc_timer *timer;
list_for_each_entry(timer, &gptc_heartbeat_list, heartbeat) {
if (!timer->used) {
gptc_per_timer_init(timer);
timer->used = true;
gptc_get(timer->gptc);
pr_debug("gptc %d timer %d heartbeat register @cpu%d\n",
timer->gptcid, timer->tid, timer->cpuid);
return 0;
}
}
return -EINVAL;
}
arch_initcall(gptc_heartbeat_init);
static void *gptc_seq_start(struct seq_file *s, loff_t *pos)
{
if (list_empty(&gptc_list))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment