[PATCH 04/30] leon, tlib: added timer width mask information

Daniel Hellstrom daniel at gaisler.com
Thu Apr 13 19:31:13 UTC 2017


---
 c/src/lib/libbsp/sparc/shared/include/tlib.h  |  8 ++++++++
 c/src/lib/libbsp/sparc/shared/timer/gptimer.c | 16 ++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/c/src/lib/libbsp/sparc/shared/include/tlib.h b/c/src/lib/libbsp/sparc/shared/include/tlib.h
index 7e6c49a..5e49dd4 100644
--- a/c/src/lib/libbsp/sparc/shared/include/tlib.h
+++ b/c/src/lib/libbsp/sparc/shared/include/tlib.h
@@ -43,6 +43,7 @@ struct tlib_drv {
 	void	(*get_counter)(struct tlib_dev *hand, unsigned int *counter);
 	int	(*custom)(struct tlib_dev *hand, int cmd, void *arg);
 	int	(*int_pend)(struct tlib_dev *hand, int ack);
+	void	(*get_widthmask)(struct tlib_dev *hand, unsigned int *widthmask);
 };
 
 struct tlib_dev {
@@ -183,6 +184,13 @@ static inline int tlib_interrupt_pending(void *hand, int ack)
 	return dev->drv->int_pend(dev, ack);
 }
 
+static inline void tlib_get_widthmask(void *hand, unsigned int *widthmask)
+{
+	struct tlib_dev *dev = hand;
+
+	dev->drv->get_widthmask(dev, widthmask);
+}
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/c/src/lib/libbsp/sparc/shared/timer/gptimer.c b/c/src/lib/libbsp/sparc/shared/timer/gptimer.c
index f8c6da2..f47952f 100644
--- a/c/src/lib/libbsp/sparc/shared/timer/gptimer.c
+++ b/c/src/lib/libbsp/sparc/shared/timer/gptimer.c
@@ -93,6 +93,7 @@ struct gptimer_priv {
 	struct gptimer_regs *regs;
 	unsigned int base_clk;
 	unsigned int base_freq;
+	unsigned int widthmask;
 	char separate_interrupt;
 	char isr_installed;
 
@@ -265,6 +266,10 @@ int gptimer_init1(struct drvmgr_dev *dev)
 	else
 		irq_ack_mask = ~0;
 
+	/* Probe timer register width mask */
+	priv->regs->timer[timer_start].value = 0xffffffff;
+	priv->widthmask = priv->regs->timer[timer_start].value;
+
 	priv->timer_cnt = timer_cnt;
 	for (i=0; i<timer_cnt; i++) {
 		timer = &priv->timers[i];
@@ -493,6 +498,16 @@ static void gptimer_tlib_get_counter(
 	*counter = timer->tregs->value;
 }
 
+static void gptimer_tlib_get_widthmask(
+	struct tlib_dev *hand,
+	unsigned int *widthmask)
+{
+	struct gptimer_timer *timer = (struct gptimer_timer *)hand;
+	struct gptimer_priv *priv = priv_from_timer(timer);
+
+	*widthmask = priv->widthmask;
+}
+
 static struct tlib_drv gptimer_tlib_drv =
 {
 	.reset = gptimer_tlib_reset,
@@ -506,4 +521,5 @@ static struct tlib_drv gptimer_tlib_drv =
 	.get_counter = gptimer_tlib_get_counter,
 	.custom = NULL,
 	.int_pend = gptimer_tlib_int_pend,
+	.get_widthmask = gptimer_tlib_get_widthmask,
 };
-- 
2.7.4




More information about the devel mailing list