aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clocksource/sh_cmt.c
diff options
context:
space:
mode:
authorMagnus Damm <damm@opensource.se>2012-12-14 00:54:28 -0500
committerSimon Horman <horms+renesas@verge.net.au>2013-03-12 13:24:36 -0400
commitcccd70455c351604d0a9075d35298ed4ff66dab3 (patch)
treef10ef71645062f0de68bdeff35021e9bf653d115 /drivers/clocksource/sh_cmt.c
parenta6a912ca43843d43590ce5f1cbc85cbc7ac14bba (diff)
clocksource: sh_cmt: Add control register callbacks
This patch adds control register callbacks for the CMT driver. At this point only 16-bit access is supported but in the future this will be updated to allow 32-bit access as well. Signed-off-by: Magnus Damm <damm@opensource.se> Acked-by: John Stultz <john.stultz@linaro.org> Tested-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Diffstat (limited to 'drivers/clocksource/sh_cmt.c')
-rw-r--r--drivers/clocksource/sh_cmt.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
index da904d7f7530..7108963a6ab8 100644
--- a/drivers/clocksource/sh_cmt.c
+++ b/drivers/clocksource/sh_cmt.c
@@ -55,6 +55,11 @@ struct sh_cmt_priv {
55 unsigned long total_cycles; 55 unsigned long total_cycles;
56 bool cs_enabled; 56 bool cs_enabled;
57 57
58 /* callbacks for CMSTR and CMCSR access */
59 unsigned long (*read_control)(void __iomem *base, unsigned long offs);
60 void (*write_control)(void __iomem *base, unsigned long offs,
61 unsigned long value);
62
58 /* callbacks for CMCNT and CMCOR access */ 63 /* callbacks for CMCNT and CMCOR access */
59 unsigned long (*read_count)(void __iomem *base, unsigned long offs); 64 unsigned long (*read_count)(void __iomem *base, unsigned long offs);
60 void (*write_count)(void __iomem *base, unsigned long offs, 65 void (*write_count)(void __iomem *base, unsigned long offs,
@@ -91,12 +96,12 @@ static inline unsigned long sh_cmt_read_cmstr(struct sh_cmt_priv *p)
91{ 96{
92 struct sh_timer_config *cfg = p->pdev->dev.platform_data; 97 struct sh_timer_config *cfg = p->pdev->dev.platform_data;
93 98
94 return sh_cmt_read16(p->mapbase - cfg->channel_offset, 0); 99 return p->read_control(p->mapbase - cfg->channel_offset, 0);
95} 100}
96 101
97static inline unsigned long sh_cmt_read_cmcsr(struct sh_cmt_priv *p) 102static inline unsigned long sh_cmt_read_cmcsr(struct sh_cmt_priv *p)
98{ 103{
99 return sh_cmt_read16(p->mapbase, CMCSR); 104 return p->read_control(p->mapbase, CMCSR);
100} 105}
101 106
102static inline unsigned long sh_cmt_read_cmcnt(struct sh_cmt_priv *p) 107static inline unsigned long sh_cmt_read_cmcnt(struct sh_cmt_priv *p)
@@ -109,13 +114,13 @@ static inline void sh_cmt_write_cmstr(struct sh_cmt_priv *p,
109{ 114{
110 struct sh_timer_config *cfg = p->pdev->dev.platform_data; 115 struct sh_timer_config *cfg = p->pdev->dev.platform_data;
111 116
112 sh_cmt_write16(p->mapbase - cfg->channel_offset, 0, value); 117 p->write_control(p->mapbase - cfg->channel_offset, 0, value);
113} 118}
114 119
115static inline void sh_cmt_write_cmcsr(struct sh_cmt_priv *p, 120static inline void sh_cmt_write_cmcsr(struct sh_cmt_priv *p,
116 unsigned long value) 121 unsigned long value)
117{ 122{
118 sh_cmt_write16(p->mapbase, CMCSR, value); 123 p->write_control(p->mapbase, CMCSR, value);
119} 124}
120 125
121static inline void sh_cmt_write_cmcnt(struct sh_cmt_priv *p, 126static inline void sh_cmt_write_cmcnt(struct sh_cmt_priv *p,
@@ -702,6 +707,9 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev)
702 goto err1; 707 goto err1;
703 } 708 }
704 709
710 p->read_control = sh_cmt_read16;
711 p->write_control = sh_cmt_write16;
712
705 if (resource_size(res) == 6) { 713 if (resource_size(res) == 6) {
706 p->width = 16; 714 p->width = 16;
707 p->read_count = sh_cmt_read16; 715 p->read_count = sh_cmt_read16;