1
From ac1ab32e1e31c9e3d0ed353e2965df1493aa70a7 Mon Sep 17 00:00:00 2001
2
From: =?UTF-8?q?Juha=20Riihim=C3=A4ki?= <juha.riihimaki@nokia.com>
3
Date: Mon, 18 Feb 2013 16:58:25 +0000
4
Subject: [PATCH 15/77] hw/omap_synctimer.c: Add OMAP3 synctimer
6
Content-Type: text/plain; charset=UTF-8
7
Content-Transfer-Encoding: 8bit
9
Add the OMAP3 synctimer.
11
TODO: is the handling of halfword reads really correct??
12
-- yes, this is allowing a 32 bit counter to be read as two
13
16 bit reads without getting two out-of-sync parts
14
(the trm talks about this albeit extremely vaguely)
15
TODO: can we avoid using the backcompat old_mmio ?
17
Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
18
[Riku Voipio: Fixes and restructuring patchset]
19
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
20
[Peter Maydell: More fixes and cleanups for upstream submission]
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
hw/omap_synctimer.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++--
24
1 file changed, 58 insertions(+), 2 deletions(-)
26
diff --git a/hw/omap_synctimer.c b/hw/omap_synctimer.c
27
index 945711e..122cb4f 100644
28
--- a/hw/omap_synctimer.c
29
+++ b/hw/omap_synctimer.c
30
@@ -24,6 +24,7 @@ struct omap_synctimer_s {
34
+ uint32_t sysconfig; /*OMAP3*/
37
/* 32-kHz Sync Timer of the OMAP2 */
38
@@ -52,6 +53,14 @@ static uint32_t omap_synctimer_readw(void *opaque, hwaddr addr)
42
+static uint32_t omap3_synctimer_readw(void *opaque, hwaddr addr)
44
+ struct omap_synctimer_s *s = (struct omap_synctimer_s *)opaque;
45
+ return (addr == 0x04)
47
+ : omap_synctimer_readw(opaque, addr);
50
static uint32_t omap_synctimer_readh(void *opaque, hwaddr addr)
52
struct omap_synctimer_s *s = (struct omap_synctimer_s *) opaque;
53
@@ -66,12 +75,38 @@ static uint32_t omap_synctimer_readh(void *opaque, hwaddr addr)
57
+static uint32_t omap3_synctimer_readh(void *opaque, hwaddr addr)
59
+ struct omap_synctimer_s *s = (struct omap_synctimer_s *) opaque;
66
+ ret = omap3_synctimer_readw(opaque, addr);
67
+ s->readh = ret >> 16;
68
+ return ret & 0xffff;
71
static void omap_synctimer_write(void *opaque, hwaddr addr,
78
+static void omap3_synctimer_write(void *opaque, hwaddr addr,
81
+ struct omap_synctimer_s *s = (struct omap_synctimer_s *)opaque;
83
+ s->sysconfig = value & 0x0c;
89
static const MemoryRegionOps omap_synctimer_ops = {
92
@@ -88,14 +123,35 @@ static const MemoryRegionOps omap_synctimer_ops = {
93
.endianness = DEVICE_NATIVE_ENDIAN,
96
+static const MemoryRegionOps omap3_synctimer_ops = {
99
+ omap_badwidth_read32,
100
+ omap3_synctimer_readh,
101
+ omap3_synctimer_readw,
104
+ omap_badwidth_write32,
105
+ omap3_synctimer_write,
106
+ omap3_synctimer_write,
109
+ .endianness = DEVICE_NATIVE_ENDIAN,
112
struct omap_synctimer_s *omap_synctimer_init(struct omap_target_agent_s *ta,
113
struct omap_mpu_state_s *mpu, omap_clk fclk, omap_clk iclk)
115
struct omap_synctimer_s *s = g_malloc0(sizeof(*s));
117
omap_synctimer_reset(s);
118
- memory_region_init_io(&s->iomem, &omap_synctimer_ops, s, "omap.synctimer",
119
- omap_l4_region_size(ta, 0));
120
+ if (cpu_class_omap3(mpu)) {
121
+ memory_region_init_io(&s->iomem, &omap3_synctimer_ops, s,
122
+ "omap.synctimer", omap_l4_region_size(ta, 0));
124
+ memory_region_init_io(&s->iomem, &omap_synctimer_ops, s,
125
+ "omap.synctimer", omap_l4_region_size(ta, 0));
127
omap_l4_attach(ta, 0, &s->iomem);