1
From cd1ca5d102477c4d9706ad21e682ab22df8eb164 Mon Sep 17 00:00:00 2001
2
From: Riku Voipio <riku.voipio@nokia.com>
3
Date: Mon, 18 Feb 2013 16:58:25 +0000
4
Subject: [PATCH 12/70] hw/omap_l4.c: Add OMAP3 support
6
TODO: definitely need to look more closely at what's going on here.
8
Drop omap3_l4ta save/load support?
10
hw/arm/omap2.c | 8 ++++----
11
hw/misc/omap_l4.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++----
12
include/hw/arm/omap.h | 39 ++++++++++++++++++++++++++-----------
13
3 files changed, 82 insertions(+), 19 deletions(-)
15
diff --git a/hw/arm/omap2.c b/hw/arm/omap2.c
16
index 36efde0..2a0b45f 100644
19
@@ -934,7 +934,7 @@ static const struct omap_l4_region_s omap_l4_region[125] = {
20
[124] = { 0xb3000, 0x1000, 32 | 16 | 8 }, /* L4TA39 */
23
-static const struct omap_l4_agent_info_s omap_l4_agent_info[54] = {
24
+static const struct omap2_l4_agent_info_s omap2_l4_agent_info[54] = {
25
{ 0, 0, 3, 2 }, /* L4IA initiatior agent */
26
{ L4TAO(1), 3, 2, 1 }, /* Control and pinout module */
27
{ L4TAO(2), 5, 2, 1 }, /* 32K timer */
28
@@ -992,9 +992,9 @@ static const struct omap_l4_agent_info_s omap_l4_agent_info[54] = {
31
#define omap_l4ta(bus, cs) \
32
- omap_l4ta_get(bus, omap_l4_region, omap_l4_agent_info, L4TA(cs))
33
+ omap2_l4ta_init(bus, omap_l4_region, omap2_l4_agent_info, L4TA(cs))
34
#define omap_l4tao(bus, cs) \
35
- omap_l4ta_get(bus, omap_l4_region, omap_l4_agent_info, L4TAO(cs))
36
+ omap2_l4ta_init(bus, omap_l4_region, omap2_l4_agent_info, L4TAO(cs))
38
/* Power, Reset, and Clock Management */
40
@@ -2273,7 +2273,7 @@ struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion *sysmem,
41
vmstate_register_ram_global(&s->sram);
42
memory_region_add_subregion(sysmem, OMAP2_SRAM_BASE, &s->sram);
44
- s->l4 = omap_l4_init(sysmem, OMAP2_L4_BASE, 54);
45
+ s->l4 = omap_l4_init(sysmem, OMAP2_L4_BASE, 54, 125);
47
/* Actually mapped at any 2K boundary in the ARM11 private-peripheral if */
48
s->ih[0] = qdev_create(NULL, "omap2-intc");
49
diff --git a/hw/misc/omap_l4.c b/hw/misc/omap_l4.c
50
index f237250..67fac43 100644
51
--- a/hw/misc/omap_l4.c
52
+++ b/hw/misc/omap_l4.c
53
@@ -28,7 +28,8 @@ struct omap_l4_s {
56
struct omap_l4_s *omap_l4_init(MemoryRegion *address_space,
57
- hwaddr base, int ta_num)
58
+ hwaddr base, int ta_num,
61
struct omap_l4_s *bus = g_malloc0(
62
sizeof(*bus) + ta_num * sizeof(*bus->ta));
63
@@ -108,14 +109,14 @@ static const MemoryRegionOps omap_l4ta_ops = {
64
.endianness = DEVICE_NATIVE_ENDIAN,
67
-struct omap_target_agent_s *omap_l4ta_get(struct omap_l4_s *bus,
68
+struct omap_target_agent_s *omap2_l4ta_init(struct omap_l4_s *bus,
69
const struct omap_l4_region_s *regions,
70
- const struct omap_l4_agent_info_s *agents,
71
+ const struct omap2_l4_agent_info_s *agents,
75
struct omap_target_agent_s *ta = NULL;
76
- const struct omap_l4_agent_info_s *info = NULL;
77
+ const struct omap2_l4_agent_info_s *info = NULL;
79
for (i = 0; i < bus->ta_num; i ++)
80
if (agents[i].ta == cs) {
81
@@ -160,3 +161,48 @@ hwaddr omap_l4_attach(struct omap_target_agent_s *ta,
86
+struct omap_target_agent_s *omap3_l4ta_init(
87
+ struct omap_l4_s *bus,
88
+ const struct omap_l4_region_s *regions,
89
+ const struct omap3_l4_agent_info_s *agents,
93
+ struct omap_target_agent_s *ta = NULL;
94
+ const struct omap3_l4_agent_info_s *info = NULL;
96
+ for (i = 0; i < bus->ta_num; i++)
97
+ if (agents[i].agent_id == cs) {
103
+ hw_error("%s: invalid agent id (%i)", __func__, cs);
106
+ hw_error("%s: target agent (%d) already initialized", __func__, cs);
110
+ ta->start = ®ions[info->first_region_id];
111
+ ta->regions = info->region_count;
113
+ ta->component = ('Q' << 24) | ('E' << 16) | ('M' << 8) | ('U' << 0);
114
+ ta->status = 0x00000000;
115
+ ta->control = 0x00000200;
117
+ for (i = 0; i < info->region_count; i++) {
118
+ if (regions[info->first_region_id + i].access == L4TYPE_TA) {
122
+ if (i >= info->region_count) {
123
+ hw_error("%s: specified agent (%d) has no TA region", __func__, cs);
126
+ ta->base = ta->bus->base + ta->start[i].offset;
130
diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h
131
index 5e9d41d..161a217 100644
132
--- a/include/hw/arm/omap.h
133
+++ b/include/hw/arm/omap.h
134
@@ -73,17 +73,25 @@ void omap_clk_reparent(omap_clk clk, omap_clk parent);
136
/* OMAP2 l4 Interconnect */
138
-struct omap_l4_region_s {
143
-struct omap_l4_agent_info_s {
144
+struct omap_l4_region_s;
146
+ L4TYPE_GENERIC = 0, /* not mapped by default, must be mapped separately */
147
+ L4TYPE_IA, /* initiator agent */
148
+ L4TYPE_TA, /* target agent */
149
+ L4TYPE_LA, /* link register agent */
150
+ L4TYPE_AP /* address protection */
151
+} omap3_l4_region_type_t;
152
+struct omap2_l4_agent_info_s {
158
+struct omap3_l4_agent_info_s {
160
+ int first_region_id;
163
struct omap_target_agent_s {
165
struct omap_l4_s *bus;
166
@@ -94,14 +102,23 @@ struct omap_target_agent_s {
170
+struct omap_l4_region_s {
173
+ int access; /* omap3_l4_region_type_t for OMAP3 */
175
struct omap_l4_s *omap_l4_init(MemoryRegion *address_space,
176
- hwaddr base, int ta_num);
178
-struct omap_target_agent_s;
179
-struct omap_target_agent_s *omap_l4ta_get(
180
+ hwaddr base, int ta_num,
182
+struct omap_target_agent_s *omap2_l4ta_init(
183
+ struct omap_l4_s *bus,
184
+ const struct omap_l4_region_s *regions,
185
+ const struct omap2_l4_agent_info_s *agents,
187
+struct omap_target_agent_s *omap3_l4ta_init(
188
struct omap_l4_s *bus,
189
const struct omap_l4_region_s *regions,
190
- const struct omap_l4_agent_info_s *agents,
191
+ const struct omap3_l4_agent_info_s *agents,
193
hwaddr omap_l4_attach(struct omap_target_agent_s *ta,
194
int region, MemoryRegion *mr);