counter: cmsdk: Add common interface

This patch adds a common interface for timers and counters based on
CMSDK APB timers.

Jira: ZEP-1300
Change-Id: I1f89f674d31410f19b651cd904c79f8d173a5357
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
This commit is contained in:
Vincenzo Frascino 2017-01-20 16:07:37 +00:00 committed by Kumar Gala
parent dee8ef6f4f
commit 06f6d3837b
2 changed files with 41 additions and 20 deletions

View file

@ -10,26 +10,7 @@
#include <init.h>
#include <soc.h>
struct timer_cmsdk_apb {
/* Offset: 0x000 (R/W) control register */
volatile uint32_t ctrl;
/* Offset: 0x004 (R/W) current value register */
volatile uint32_t value;
/* Offset: 0x008 (R/W) reload value register */
volatile uint32_t reload;
union {
/* Offset: 0x00C (R/ ) interrupt status register */
volatile uint32_t intstatus;
/* Offset: 0x00C ( /W) interruptclear register */
volatile uint32_t intclear;
} intreg;
};
#define TIMER_CTRL_IRQ_EN (1 << 3)
#define TIMER_CTRL_SEL_EXT_CLK (1 << 2)
#define TIMER_CTRL_SEL_EXT_EN (1 << 1)
#define TIMER_CTRL_EN (1 << 0)
#define TIMER_CTRL_INT_CLEAR (1 << 0)
#include "timer_cmsdk_apb.h"
#define TIMER_MAX_RELOAD 0xFFFFFFFF

View file

@ -0,0 +1,40 @@
/*
* Copyright (c) 2017 Linaro Limited.
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _DRIVERS_TIMER_CMSDK_AHB_
#define _DRIVERS_TIMER_CMSDK_AHB_
#include <counter.h>
#ifdef __cplusplus
extern "C" {
#endif
struct timer_cmsdk_apb {
/* Offset: 0x000 (R/W) control register */
volatile uint32_t ctrl;
/* Offset: 0x004 (R/W) current value register */
volatile uint32_t value;
/* Offset: 0x008 (R/W) reload value register */
volatile uint32_t reload;
union {
/* Offset: 0x00C (R/ ) interrupt status register */
volatile uint32_t intstatus;
/* Offset: 0x00C ( /W) interruptclear register */
volatile uint32_t intclear;
};
};
#define TIMER_CTRL_IRQ_EN (1 << 3)
#define TIMER_CTRL_SEL_EXT_CLK (1 << 2)
#define TIMER_CTRL_SEL_EXT_EN (1 << 1)
#define TIMER_CTRL_EN (1 << 0)
#define TIMER_CTRL_INT_CLEAR (1 << 0)
#ifdef __cplusplus
}
#endif
#endif /* _DRIVERS_TIMER_CMSDK_AHB_ */