2 * Status and system control registers for ARM RealView/Versatile boards.
4 * Copyright (c) 2006-2007 CodeSourcery.
5 * Written by Paul Brook
7 * This code is licenced under the GPL.
11 #include "primecell.h"
14 #define LOCK_VALUE 0xa05f
27 static uint32_t arm_sysctl_read(void *opaque
, target_phys_addr_t offset
)
29 arm_sysctl_state
*s
= (arm_sysctl_state
*)opaque
;
35 /* General purpose hardware switches.
36 We don't have a useful way of exposing these to the user. */
47 case 0x24: /* 100HZ */
48 /* ??? Implement these. */
50 case 0x28: /* CFGDATA1 */
52 case 0x2c: /* CFGDATA2 */
54 case 0x30: /* FLAGS */
56 case 0x38: /* NVFLAGS */
58 case 0x40: /* RESETCTL */
60 case 0x44: /* PCICTL */
64 case 0x4c: /* FLASH */
68 case 0x54: /* CLCDSER */
70 case 0x58: /* BOOTCS */
72 case 0x5c: /* 24MHz */
73 /* ??? not implemented. */
77 case 0x84: /* PROCID0 */
78 /* ??? Don't know what the proper value for the core tile ID is. */
80 case 0x88: /* PROCID1 */
82 case 0x64: /* DMAPSR0 */
83 case 0x68: /* DMAPSR1 */
84 case 0x6c: /* DMAPSR2 */
85 case 0x70: /* IOSEL */
86 case 0x74: /* PLDCTL */
87 case 0x80: /* BUSID */
88 case 0x8c: /* OSCRESET0 */
89 case 0x90: /* OSCRESET1 */
90 case 0x94: /* OSCRESET2 */
91 case 0x98: /* OSCRESET3 */
92 case 0x9c: /* OSCRESET4 */
93 case 0xc0: /* SYS_TEST_OSC0 */
94 case 0xc4: /* SYS_TEST_OSC1 */
95 case 0xc8: /* SYS_TEST_OSC2 */
96 case 0xcc: /* SYS_TEST_OSC3 */
97 case 0xd0: /* SYS_TEST_OSC4 */
100 printf ("arm_sysctl_read: Bad register offset 0x%x\n", (int)offset
);
105 static void arm_sysctl_write(void *opaque
, target_phys_addr_t offset
,
108 arm_sysctl_state
*s
= (arm_sysctl_state
*)opaque
;
113 case 0x0c: /* OSC0 */
114 case 0x10: /* OSC1 */
115 case 0x14: /* OSC2 */
116 case 0x18: /* OSC3 */
117 case 0x1c: /* OSC4 */
120 case 0x20: /* LOCK */
121 if (val
== LOCK_VALUE
)
124 s
->lockval
= val
& 0x7fff;
126 case 0x28: /* CFGDATA1 */
127 /* ??? Need to implement this. */
130 case 0x2c: /* CFGDATA2 */
131 /* ??? Need to implement this. */
134 case 0x30: /* FLAGSSET */
137 case 0x34: /* FLAGSCLR */
140 case 0x38: /* NVFLAGSSET */
143 case 0x3c: /* NVFLAGSCLR */
146 case 0x40: /* RESETCTL */
147 if (s
->lockval
== LOCK_VALUE
) {
150 qemu_system_reset_request ();
153 case 0x44: /* PCICTL */
156 case 0x4c: /* FLASH */
157 case 0x50: /* CLCD */
158 case 0x54: /* CLCDSER */
159 case 0x64: /* DMAPSR0 */
160 case 0x68: /* DMAPSR1 */
161 case 0x6c: /* DMAPSR2 */
162 case 0x70: /* IOSEL */
163 case 0x74: /* PLDCTL */
164 case 0x80: /* BUSID */
165 case 0x84: /* PROCID0 */
166 case 0x88: /* PROCID1 */
167 case 0x8c: /* OSCRESET0 */
168 case 0x90: /* OSCRESET1 */
169 case 0x94: /* OSCRESET2 */
170 case 0x98: /* OSCRESET3 */
171 case 0x9c: /* OSCRESET4 */
174 printf ("arm_sysctl_write: Bad register offset 0x%x\n", (int)offset
);
179 static CPUReadMemoryFunc
*arm_sysctl_readfn
[] = {
185 static CPUWriteMemoryFunc
*arm_sysctl_writefn
[] = {
191 void arm_sysctl_init(uint32_t base
, uint32_t sys_id
)
196 s
= (arm_sysctl_state
*)qemu_mallocz(sizeof(arm_sysctl_state
));
198 /* The MPcore bootloader uses these flags to start secondary CPUs.
199 We don't use a bootloader, so do this here. */
201 iomemtype
= cpu_register_io_memory(0, arm_sysctl_readfn
,
202 arm_sysctl_writefn
, s
);
203 cpu_register_physical_memory(base
, 0x00001000, iomemtype
);
204 /* ??? Save/restore. */