2 * ARM dummy L210, L220, PL310 cache controller.
4 * Copyright (c) 2010-2012 Calxeda
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2 or any later version, as published by the Free Software
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along with
17 * this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "hw/sysbus.h"
24 #define CACHE_ID 0x410000c8
26 #define TYPE_ARM_L2X0 "l2x0"
27 #define ARM_L2X0(obj) OBJECT_CHECK(L2x0State, (obj), TYPE_ARM_L2X0)
29 typedef struct L2x0State
{
30 SysBusDevice parent_obj
;
38 uint32_t filter_start
;
42 static const VMStateDescription vmstate_l2x0
= {
45 .minimum_version_id
= 1,
46 .fields
= (VMStateField
[]) {
47 VMSTATE_UINT32(ctrl
, L2x0State
),
48 VMSTATE_UINT32(aux_ctrl
, L2x0State
),
49 VMSTATE_UINT32(data_ctrl
, L2x0State
),
50 VMSTATE_UINT32(tag_ctrl
, L2x0State
),
51 VMSTATE_UINT32(filter_start
, L2x0State
),
52 VMSTATE_UINT32(filter_end
, L2x0State
),
58 static uint64_t l2x0_priv_read(void *opaque
, hwaddr offset
,
62 L2x0State
*s
= (L2x0State
*)opaque
;
64 if (offset
>= 0x730 && offset
< 0x800) {
65 return 0; /* cache ops complete */
71 /* aux_ctrl values affect cache_type values */
72 cache_data
= (s
->aux_ctrl
& (7 << 17)) >> 15;
73 cache_data
|= (s
->aux_ctrl
& (1 << 16)) >> 16;
74 return s
->cache_type
|= (cache_data
<< 18) | (cache_data
<< 6);
84 return s
->filter_start
;
94 qemu_log_mask(LOG_GUEST_ERROR
,
95 "l2x0_priv_read: Bad offset %x\n", (int)offset
);
101 static void l2x0_priv_write(void *opaque
, hwaddr offset
,
102 uint64_t value
, unsigned size
)
104 L2x0State
*s
= (L2x0State
*)opaque
;
106 if (offset
>= 0x730 && offset
< 0x800) {
121 s
->data_ctrl
= value
;
124 s
->filter_start
= value
;
127 s
->filter_end
= value
;
136 qemu_log_mask(LOG_GUEST_ERROR
,
137 "l2x0_priv_write: Bad offset %x\n", (int)offset
);
142 static void l2x0_priv_reset(DeviceState
*dev
)
144 L2x0State
*s
= ARM_L2X0(dev
);
147 s
->aux_ctrl
= 0x02020000;
154 static const MemoryRegionOps l2x0_mem_ops
= {
155 .read
= l2x0_priv_read
,
156 .write
= l2x0_priv_write
,
157 .endianness
= DEVICE_NATIVE_ENDIAN
,
160 static int l2x0_priv_init(SysBusDevice
*dev
)
162 L2x0State
*s
= ARM_L2X0(dev
);
164 memory_region_init_io(&s
->iomem
, OBJECT(dev
), &l2x0_mem_ops
, s
,
166 sysbus_init_mmio(dev
, &s
->iomem
);
170 static Property l2x0_properties
[] = {
171 DEFINE_PROP_UINT32("cache-type", L2x0State
, cache_type
, 0x1c100100),
172 DEFINE_PROP_END_OF_LIST(),
175 static void l2x0_class_init(ObjectClass
*klass
, void *data
)
177 SysBusDeviceClass
*k
= SYS_BUS_DEVICE_CLASS(klass
);
178 DeviceClass
*dc
= DEVICE_CLASS(klass
);
180 k
->init
= l2x0_priv_init
;
181 dc
->vmsd
= &vmstate_l2x0
;
182 dc
->props
= l2x0_properties
;
183 dc
->reset
= l2x0_priv_reset
;
186 static const TypeInfo l2x0_info
= {
187 .name
= TYPE_ARM_L2X0
,
188 .parent
= TYPE_SYS_BUS_DEVICE
,
189 .instance_size
= sizeof(L2x0State
),
190 .class_init
= l2x0_class_init
,
193 static void l2x0_register_types(void)
195 type_register_static(&l2x0_info
);
198 type_init(l2x0_register_types
)