2 * StrongARM SA-1100/SA-1110 emulation
4 * Copyright (C) 2011 Dmitry Eremin-Solenikov
6 * Largely based on StrongARM emulation:
7 * Copyright (c) 2006 Openedhand Ltd.
8 * Written by Andrzej Zaborowski <balrog@zabor.org>
10 * UART code based on QEMU 16550A UART emulation
11 * Copyright (c) 2003-2004 Fabrice Bellard
12 * Copyright (c) 2008 Citrix Systems, Inc.
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License version 2 as
16 * published by the Free Software Foundation.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, see <http://www.gnu.org/licenses/>.
26 * Contributions after 2012-01-13 are licensed under the terms of the
27 * GNU GPL, version 2 or (at your option) any later version.
30 #include "qemu/osdep.h"
32 #include "hw/qdev-properties.h"
33 #include "hw/qdev-properties-system.h"
34 #include "hw/sysbus.h"
35 #include "migration/vmstate.h"
36 #include "strongarm.h"
37 #include "qemu/error-report.h"
38 #include "hw/arm/boot.h"
39 #include "chardev/char-fe.h"
40 #include "chardev/char-serial.h"
41 #include "sysemu/sysemu.h"
42 #include "sysemu/rtc.h"
43 #include "hw/ssi/ssi.h"
44 #include "qapi/error.h"
45 #include "qemu/cutils.h"
47 #include "qom/object.h"
48 #include "target/arm/cpu-qom.h"
53 - Implement cp15, c14 ?
54 - Implement cp15, c15 !!! (idle used in L)
55 - Implement idle mode handling/DIM
56 - Implement sleep mode/Wake sources
57 - Implement reset control
58 - Implement memory control regs
60 - Maybe support MBGNT/MBREQ
65 - Enhance UART with modem signals
72 { 0x80010000, SA_PIC_UART1
},
73 { 0x80030000, SA_PIC_UART2
},
74 { 0x80050000, SA_PIC_UART3
},
78 /* Interrupt Controller */
80 #define TYPE_STRONGARM_PIC "strongarm_pic"
81 OBJECT_DECLARE_SIMPLE_TYPE(StrongARMPICState
, STRONGARM_PIC
)
83 struct StrongARMPICState
{
84 SysBusDevice parent_obj
;
103 #define SA_PIC_SRCS 32
106 static void strongarm_pic_update(void *opaque
)
108 StrongARMPICState
*s
= opaque
;
110 /* FIXME: reflect DIM */
111 qemu_set_irq(s
->fiq
, s
->pending
& s
->enabled
& s
->is_fiq
);
112 qemu_set_irq(s
->irq
, s
->pending
& s
->enabled
& ~s
->is_fiq
);
115 static void strongarm_pic_set_irq(void *opaque
, int irq
, int level
)
117 StrongARMPICState
*s
= opaque
;
120 s
->pending
|= 1 << irq
;
122 s
->pending
&= ~(1 << irq
);
125 strongarm_pic_update(s
);
128 static uint64_t strongarm_pic_mem_read(void *opaque
, hwaddr offset
,
131 StrongARMPICState
*s
= opaque
;
135 return s
->pending
& ~s
->is_fiq
& s
->enabled
;
141 return s
->int_idle
== 0;
143 return s
->pending
& s
->is_fiq
& s
->enabled
;
147 qemu_log_mask(LOG_GUEST_ERROR
,
148 "%s: Bad register offset 0x"HWADDR_FMT_plx
"\n",
154 static void strongarm_pic_mem_write(void *opaque
, hwaddr offset
,
155 uint64_t value
, unsigned size
)
157 StrongARMPICState
*s
= opaque
;
167 s
->int_idle
= (value
& 1) ? 0 : ~0;
170 qemu_log_mask(LOG_GUEST_ERROR
,
171 "%s: Bad register offset 0x"HWADDR_FMT_plx
"\n",
175 strongarm_pic_update(s
);
178 static const MemoryRegionOps strongarm_pic_ops
= {
179 .read
= strongarm_pic_mem_read
,
180 .write
= strongarm_pic_mem_write
,
181 .endianness
= DEVICE_NATIVE_ENDIAN
,
184 static void strongarm_pic_initfn(Object
*obj
)
186 DeviceState
*dev
= DEVICE(obj
);
187 StrongARMPICState
*s
= STRONGARM_PIC(obj
);
188 SysBusDevice
*sbd
= SYS_BUS_DEVICE(obj
);
190 qdev_init_gpio_in(dev
, strongarm_pic_set_irq
, SA_PIC_SRCS
);
191 memory_region_init_io(&s
->iomem
, obj
, &strongarm_pic_ops
, s
,
193 sysbus_init_mmio(sbd
, &s
->iomem
);
194 sysbus_init_irq(sbd
, &s
->irq
);
195 sysbus_init_irq(sbd
, &s
->fiq
);
198 static int strongarm_pic_post_load(void *opaque
, int version_id
)
200 strongarm_pic_update(opaque
);
204 static const VMStateDescription vmstate_strongarm_pic_regs
= {
205 .name
= "strongarm_pic",
207 .minimum_version_id
= 0,
208 .post_load
= strongarm_pic_post_load
,
209 .fields
= (const VMStateField
[]) {
210 VMSTATE_UINT32(pending
, StrongARMPICState
),
211 VMSTATE_UINT32(enabled
, StrongARMPICState
),
212 VMSTATE_UINT32(is_fiq
, StrongARMPICState
),
213 VMSTATE_UINT32(int_idle
, StrongARMPICState
),
214 VMSTATE_END_OF_LIST(),
218 static void strongarm_pic_class_init(ObjectClass
*klass
, void *data
)
220 DeviceClass
*dc
= DEVICE_CLASS(klass
);
222 dc
->desc
= "StrongARM PIC";
223 dc
->vmsd
= &vmstate_strongarm_pic_regs
;
226 static const TypeInfo strongarm_pic_info
= {
227 .name
= TYPE_STRONGARM_PIC
,
228 .parent
= TYPE_SYS_BUS_DEVICE
,
229 .instance_size
= sizeof(StrongARMPICState
),
230 .instance_init
= strongarm_pic_initfn
,
231 .class_init
= strongarm_pic_class_init
,
234 /* Real-Time Clock */
235 #define RTAR 0x00 /* RTC Alarm register */
236 #define RCNR 0x04 /* RTC Counter register */
237 #define RTTR 0x08 /* RTC Timer Trim register */
238 #define RTSR 0x10 /* RTC Status register */
240 #define RTSR_AL (1 << 0) /* RTC Alarm detected */
241 #define RTSR_HZ (1 << 1) /* RTC 1Hz detected */
242 #define RTSR_ALE (1 << 2) /* RTC Alarm enable */
243 #define RTSR_HZE (1 << 3) /* RTC 1Hz enable */
245 /* 16 LSB of RTTR are clockdiv for internal trim logic,
246 * trim delete isn't emulated, so
247 * f = 32 768 / (RTTR_trim + 1) */
249 #define TYPE_STRONGARM_RTC "strongarm-rtc"
250 OBJECT_DECLARE_SIMPLE_TYPE(StrongARMRTCState
, STRONGARM_RTC
)
252 struct StrongARMRTCState
{
253 SysBusDevice parent_obj
;
261 QEMUTimer
*rtc_alarm
;
267 static inline void strongarm_rtc_int_update(StrongARMRTCState
*s
)
269 qemu_set_irq(s
->rtc_irq
, s
->rtsr
& RTSR_AL
);
270 qemu_set_irq(s
->rtc_hz_irq
, s
->rtsr
& RTSR_HZ
);
273 static void strongarm_rtc_hzupdate(StrongARMRTCState
*s
)
275 int64_t rt
= qemu_clock_get_ms(rtc_clock
);
276 s
->last_rcnr
+= ((rt
- s
->last_hz
) << 15) /
277 (1000 * ((s
->rttr
& 0xffff) + 1));
281 static inline void strongarm_rtc_timer_update(StrongARMRTCState
*s
)
283 if ((s
->rtsr
& RTSR_HZE
) && !(s
->rtsr
& RTSR_HZ
)) {
284 timer_mod(s
->rtc_hz
, s
->last_hz
+ 1000);
286 timer_del(s
->rtc_hz
);
289 if ((s
->rtsr
& RTSR_ALE
) && !(s
->rtsr
& RTSR_AL
)) {
290 timer_mod(s
->rtc_alarm
, s
->last_hz
+
291 (((s
->rtar
- s
->last_rcnr
) * 1000 *
292 ((s
->rttr
& 0xffff) + 1)) >> 15));
294 timer_del(s
->rtc_alarm
);
298 static inline void strongarm_rtc_alarm_tick(void *opaque
)
300 StrongARMRTCState
*s
= opaque
;
302 strongarm_rtc_timer_update(s
);
303 strongarm_rtc_int_update(s
);
306 static inline void strongarm_rtc_hz_tick(void *opaque
)
308 StrongARMRTCState
*s
= opaque
;
310 strongarm_rtc_timer_update(s
);
311 strongarm_rtc_int_update(s
);
314 static uint64_t strongarm_rtc_read(void *opaque
, hwaddr addr
,
317 StrongARMRTCState
*s
= opaque
;
327 return s
->last_rcnr
+
328 ((qemu_clock_get_ms(rtc_clock
) - s
->last_hz
) << 15) /
329 (1000 * ((s
->rttr
& 0xffff) + 1));
331 qemu_log_mask(LOG_GUEST_ERROR
,
332 "%s: Bad rtc register read 0x"HWADDR_FMT_plx
"\n",
338 static void strongarm_rtc_write(void *opaque
, hwaddr addr
,
339 uint64_t value
, unsigned size
)
341 StrongARMRTCState
*s
= opaque
;
346 strongarm_rtc_hzupdate(s
);
348 strongarm_rtc_timer_update(s
);
353 s
->rtsr
= (value
& (RTSR_ALE
| RTSR_HZE
)) |
354 (s
->rtsr
& ~(value
& (RTSR_AL
| RTSR_HZ
)));
356 if (s
->rtsr
!= old_rtsr
) {
357 strongarm_rtc_timer_update(s
);
360 strongarm_rtc_int_update(s
);
365 strongarm_rtc_timer_update(s
);
369 strongarm_rtc_hzupdate(s
);
370 s
->last_rcnr
= value
;
371 strongarm_rtc_timer_update(s
);
375 qemu_log_mask(LOG_GUEST_ERROR
,
376 "%s: Bad rtc register write 0x"HWADDR_FMT_plx
"\n",
381 static const MemoryRegionOps strongarm_rtc_ops
= {
382 .read
= strongarm_rtc_read
,
383 .write
= strongarm_rtc_write
,
384 .endianness
= DEVICE_NATIVE_ENDIAN
,
387 static void strongarm_rtc_init(Object
*obj
)
389 StrongARMRTCState
*s
= STRONGARM_RTC(obj
);
390 SysBusDevice
*dev
= SYS_BUS_DEVICE(obj
);
396 qemu_get_timedate(&tm
, 0);
398 s
->last_rcnr
= (uint32_t) mktimegm(&tm
);
399 s
->last_hz
= qemu_clock_get_ms(rtc_clock
);
401 sysbus_init_irq(dev
, &s
->rtc_irq
);
402 sysbus_init_irq(dev
, &s
->rtc_hz_irq
);
404 memory_region_init_io(&s
->iomem
, obj
, &strongarm_rtc_ops
, s
,
406 sysbus_init_mmio(dev
, &s
->iomem
);
409 static void strongarm_rtc_realize(DeviceState
*dev
, Error
**errp
)
411 StrongARMRTCState
*s
= STRONGARM_RTC(dev
);
412 s
->rtc_alarm
= timer_new_ms(rtc_clock
, strongarm_rtc_alarm_tick
, s
);
413 s
->rtc_hz
= timer_new_ms(rtc_clock
, strongarm_rtc_hz_tick
, s
);
416 static int strongarm_rtc_pre_save(void *opaque
)
418 StrongARMRTCState
*s
= opaque
;
420 strongarm_rtc_hzupdate(s
);
425 static int strongarm_rtc_post_load(void *opaque
, int version_id
)
427 StrongARMRTCState
*s
= opaque
;
429 strongarm_rtc_timer_update(s
);
430 strongarm_rtc_int_update(s
);
435 static const VMStateDescription vmstate_strongarm_rtc_regs
= {
436 .name
= "strongarm-rtc",
438 .minimum_version_id
= 0,
439 .pre_save
= strongarm_rtc_pre_save
,
440 .post_load
= strongarm_rtc_post_load
,
441 .fields
= (const VMStateField
[]) {
442 VMSTATE_UINT32(rttr
, StrongARMRTCState
),
443 VMSTATE_UINT32(rtsr
, StrongARMRTCState
),
444 VMSTATE_UINT32(rtar
, StrongARMRTCState
),
445 VMSTATE_UINT32(last_rcnr
, StrongARMRTCState
),
446 VMSTATE_INT64(last_hz
, StrongARMRTCState
),
447 VMSTATE_END_OF_LIST(),
451 static void strongarm_rtc_sysbus_class_init(ObjectClass
*klass
, void *data
)
453 DeviceClass
*dc
= DEVICE_CLASS(klass
);
455 dc
->desc
= "StrongARM RTC Controller";
456 dc
->vmsd
= &vmstate_strongarm_rtc_regs
;
457 dc
->realize
= strongarm_rtc_realize
;
460 static const TypeInfo strongarm_rtc_sysbus_info
= {
461 .name
= TYPE_STRONGARM_RTC
,
462 .parent
= TYPE_SYS_BUS_DEVICE
,
463 .instance_size
= sizeof(StrongARMRTCState
),
464 .instance_init
= strongarm_rtc_init
,
465 .class_init
= strongarm_rtc_sysbus_class_init
,
478 #define TYPE_STRONGARM_GPIO "strongarm-gpio"
479 OBJECT_DECLARE_SIMPLE_TYPE(StrongARMGPIOInfo
, STRONGARM_GPIO
)
481 struct StrongARMGPIOInfo
{
484 qemu_irq handler
[28];
500 static void strongarm_gpio_irq_update(StrongARMGPIOInfo
*s
)
503 for (i
= 0; i
< 11; i
++) {
504 qemu_set_irq(s
->irqs
[i
], s
->status
& (1 << i
));
507 qemu_set_irq(s
->irqX
, (s
->status
& ~0x7ff));
510 static void strongarm_gpio_set(void *opaque
, int line
, int level
)
512 StrongARMGPIOInfo
*s
= opaque
;
518 s
->status
|= s
->rising
& mask
&
519 ~s
->ilevel
& ~s
->dir
;
522 s
->status
|= s
->falling
& mask
&
527 if (s
->status
& mask
) {
528 strongarm_gpio_irq_update(s
);
532 static void strongarm_gpio_handler_update(StrongARMGPIOInfo
*s
)
534 uint32_t level
, diff
;
537 level
= s
->olevel
& s
->dir
;
539 for (diff
= s
->prev_level
^ level
; diff
; diff
^= 1 << bit
) {
541 qemu_set_irq(s
->handler
[bit
], (level
>> bit
) & 1);
544 s
->prev_level
= level
;
547 static uint64_t strongarm_gpio_read(void *opaque
, hwaddr offset
,
550 StrongARMGPIOInfo
*s
= opaque
;
553 case GPDR
: /* GPIO Pin-Direction registers */
556 case GPSR
: /* GPIO Pin-Output Set registers */
557 qemu_log_mask(LOG_GUEST_ERROR
,
558 "%s: read from write only register GPSR\n", __func__
);
561 case GPCR
: /* GPIO Pin-Output Clear registers */
562 qemu_log_mask(LOG_GUEST_ERROR
,
563 "%s: read from write only register GPCR\n", __func__
);
566 case GRER
: /* GPIO Rising-Edge Detect Enable registers */
569 case GFER
: /* GPIO Falling-Edge Detect Enable registers */
572 case GAFR
: /* GPIO Alternate Function registers */
575 case GPLR
: /* GPIO Pin-Level registers */
576 return (s
->olevel
& s
->dir
) |
577 (s
->ilevel
& ~s
->dir
);
579 case GEDR
: /* GPIO Edge Detect Status registers */
583 qemu_log_mask(LOG_GUEST_ERROR
,
584 "%s: Bad gpio read offset 0x"HWADDR_FMT_plx
"\n",
591 static void strongarm_gpio_write(void *opaque
, hwaddr offset
,
592 uint64_t value
, unsigned size
)
594 StrongARMGPIOInfo
*s
= opaque
;
597 case GPDR
: /* GPIO Pin-Direction registers */
598 s
->dir
= value
& 0x0fffffff;
599 strongarm_gpio_handler_update(s
);
602 case GPSR
: /* GPIO Pin-Output Set registers */
603 s
->olevel
|= value
& 0x0fffffff;
604 strongarm_gpio_handler_update(s
);
607 case GPCR
: /* GPIO Pin-Output Clear registers */
609 strongarm_gpio_handler_update(s
);
612 case GRER
: /* GPIO Rising-Edge Detect Enable registers */
616 case GFER
: /* GPIO Falling-Edge Detect Enable registers */
620 case GAFR
: /* GPIO Alternate Function registers */
624 case GEDR
: /* GPIO Edge Detect Status registers */
626 strongarm_gpio_irq_update(s
);
630 qemu_log_mask(LOG_GUEST_ERROR
,
631 "%s: Bad write offset 0x"HWADDR_FMT_plx
"\n",
636 static const MemoryRegionOps strongarm_gpio_ops
= {
637 .read
= strongarm_gpio_read
,
638 .write
= strongarm_gpio_write
,
639 .endianness
= DEVICE_NATIVE_ENDIAN
,
642 static DeviceState
*strongarm_gpio_init(hwaddr base
,
648 dev
= qdev_new(TYPE_STRONGARM_GPIO
);
649 sysbus_realize_and_unref(SYS_BUS_DEVICE(dev
), &error_fatal
);
651 sysbus_mmio_map(SYS_BUS_DEVICE(dev
), 0, base
);
652 for (i
= 0; i
< 12; i
++)
653 sysbus_connect_irq(SYS_BUS_DEVICE(dev
), i
,
654 qdev_get_gpio_in(pic
, SA_PIC_GPIO0_EDGE
+ i
));
659 static void strongarm_gpio_initfn(Object
*obj
)
661 DeviceState
*dev
= DEVICE(obj
);
662 StrongARMGPIOInfo
*s
= STRONGARM_GPIO(obj
);
663 SysBusDevice
*sbd
= SYS_BUS_DEVICE(obj
);
666 qdev_init_gpio_in(dev
, strongarm_gpio_set
, 28);
667 qdev_init_gpio_out(dev
, s
->handler
, 28);
669 memory_region_init_io(&s
->iomem
, obj
, &strongarm_gpio_ops
, s
,
672 sysbus_init_mmio(sbd
, &s
->iomem
);
673 for (i
= 0; i
< 11; i
++) {
674 sysbus_init_irq(sbd
, &s
->irqs
[i
]);
676 sysbus_init_irq(sbd
, &s
->irqX
);
679 static const VMStateDescription vmstate_strongarm_gpio_regs
= {
680 .name
= "strongarm-gpio",
682 .minimum_version_id
= 0,
683 .fields
= (const VMStateField
[]) {
684 VMSTATE_UINT32(ilevel
, StrongARMGPIOInfo
),
685 VMSTATE_UINT32(olevel
, StrongARMGPIOInfo
),
686 VMSTATE_UINT32(dir
, StrongARMGPIOInfo
),
687 VMSTATE_UINT32(rising
, StrongARMGPIOInfo
),
688 VMSTATE_UINT32(falling
, StrongARMGPIOInfo
),
689 VMSTATE_UINT32(status
, StrongARMGPIOInfo
),
690 VMSTATE_UINT32(gafr
, StrongARMGPIOInfo
),
691 VMSTATE_UINT32(prev_level
, StrongARMGPIOInfo
),
692 VMSTATE_END_OF_LIST(),
696 static void strongarm_gpio_class_init(ObjectClass
*klass
, void *data
)
698 DeviceClass
*dc
= DEVICE_CLASS(klass
);
700 dc
->desc
= "StrongARM GPIO controller";
701 dc
->vmsd
= &vmstate_strongarm_gpio_regs
;
704 static const TypeInfo strongarm_gpio_info
= {
705 .name
= TYPE_STRONGARM_GPIO
,
706 .parent
= TYPE_SYS_BUS_DEVICE
,
707 .instance_size
= sizeof(StrongARMGPIOInfo
),
708 .instance_init
= strongarm_gpio_initfn
,
709 .class_init
= strongarm_gpio_class_init
,
712 /* Peripheral Pin Controller */
719 #define TYPE_STRONGARM_PPC "strongarm-ppc"
720 OBJECT_DECLARE_SIMPLE_TYPE(StrongARMPPCInfo
, STRONGARM_PPC
)
722 struct StrongARMPPCInfo
{
723 SysBusDevice parent_obj
;
726 qemu_irq handler
[28];
738 static void strongarm_ppc_set(void *opaque
, int line
, int level
)
740 StrongARMPPCInfo
*s
= opaque
;
743 s
->ilevel
|= 1 << line
;
745 s
->ilevel
&= ~(1 << line
);
749 static void strongarm_ppc_handler_update(StrongARMPPCInfo
*s
)
751 uint32_t level
, diff
;
754 level
= s
->olevel
& s
->dir
;
756 for (diff
= s
->prev_level
^ level
; diff
; diff
^= 1 << bit
) {
758 qemu_set_irq(s
->handler
[bit
], (level
>> bit
) & 1);
761 s
->prev_level
= level
;
764 static uint64_t strongarm_ppc_read(void *opaque
, hwaddr offset
,
767 StrongARMPPCInfo
*s
= opaque
;
770 case PPDR
: /* PPC Pin Direction registers */
771 return s
->dir
| ~0x3fffff;
773 case PPSR
: /* PPC Pin State registers */
774 return (s
->olevel
& s
->dir
) |
775 (s
->ilevel
& ~s
->dir
) |
779 return s
->ppar
| ~0x41000;
785 return s
->ppfr
| ~0x7f001;
788 qemu_log_mask(LOG_GUEST_ERROR
,
789 "%s: Bad ppc read offset 0x"HWADDR_FMT_plx
"\n",
796 static void strongarm_ppc_write(void *opaque
, hwaddr offset
,
797 uint64_t value
, unsigned size
)
799 StrongARMPPCInfo
*s
= opaque
;
802 case PPDR
: /* PPC Pin Direction registers */
803 s
->dir
= value
& 0x3fffff;
804 strongarm_ppc_handler_update(s
);
807 case PPSR
: /* PPC Pin State registers */
808 s
->olevel
= value
& s
->dir
& 0x3fffff;
809 strongarm_ppc_handler_update(s
);
813 s
->ppar
= value
& 0x41000;
817 s
->psdr
= value
& 0x3fffff;
821 s
->ppfr
= value
& 0x7f001;
825 qemu_log_mask(LOG_GUEST_ERROR
,
826 "%s: Bad ppc write offset 0x"HWADDR_FMT_plx
"\n",
831 static const MemoryRegionOps strongarm_ppc_ops
= {
832 .read
= strongarm_ppc_read
,
833 .write
= strongarm_ppc_write
,
834 .endianness
= DEVICE_NATIVE_ENDIAN
,
837 static void strongarm_ppc_init(Object
*obj
)
839 DeviceState
*dev
= DEVICE(obj
);
840 StrongARMPPCInfo
*s
= STRONGARM_PPC(obj
);
841 SysBusDevice
*sbd
= SYS_BUS_DEVICE(obj
);
843 qdev_init_gpio_in(dev
, strongarm_ppc_set
, 22);
844 qdev_init_gpio_out(dev
, s
->handler
, 22);
846 memory_region_init_io(&s
->iomem
, obj
, &strongarm_ppc_ops
, s
,
849 sysbus_init_mmio(sbd
, &s
->iomem
);
852 static const VMStateDescription vmstate_strongarm_ppc_regs
= {
853 .name
= "strongarm-ppc",
855 .minimum_version_id
= 0,
856 .fields
= (const VMStateField
[]) {
857 VMSTATE_UINT32(ilevel
, StrongARMPPCInfo
),
858 VMSTATE_UINT32(olevel
, StrongARMPPCInfo
),
859 VMSTATE_UINT32(dir
, StrongARMPPCInfo
),
860 VMSTATE_UINT32(ppar
, StrongARMPPCInfo
),
861 VMSTATE_UINT32(psdr
, StrongARMPPCInfo
),
862 VMSTATE_UINT32(ppfr
, StrongARMPPCInfo
),
863 VMSTATE_UINT32(prev_level
, StrongARMPPCInfo
),
864 VMSTATE_END_OF_LIST(),
868 static void strongarm_ppc_class_init(ObjectClass
*klass
, void *data
)
870 DeviceClass
*dc
= DEVICE_CLASS(klass
);
872 dc
->desc
= "StrongARM PPC controller";
873 dc
->vmsd
= &vmstate_strongarm_ppc_regs
;
876 static const TypeInfo strongarm_ppc_info
= {
877 .name
= TYPE_STRONGARM_PPC
,
878 .parent
= TYPE_SYS_BUS_DEVICE
,
879 .instance_size
= sizeof(StrongARMPPCInfo
),
880 .instance_init
= strongarm_ppc_init
,
881 .class_init
= strongarm_ppc_class_init
,
893 #define UTCR0_PE (1 << 0) /* Parity enable */
894 #define UTCR0_OES (1 << 1) /* Even parity */
895 #define UTCR0_SBS (1 << 2) /* 2 stop bits */
896 #define UTCR0_DSS (1 << 3) /* 8-bit data */
898 #define UTCR3_RXE (1 << 0) /* Rx enable */
899 #define UTCR3_TXE (1 << 1) /* Tx enable */
900 #define UTCR3_BRK (1 << 2) /* Force Break */
901 #define UTCR3_RIE (1 << 3) /* Rx int enable */
902 #define UTCR3_TIE (1 << 4) /* Tx int enable */
903 #define UTCR3_LBM (1 << 5) /* Loopback */
905 #define UTSR0_TFS (1 << 0) /* Tx FIFO nearly empty */
906 #define UTSR0_RFS (1 << 1) /* Rx FIFO nearly full */
907 #define UTSR0_RID (1 << 2) /* Receiver Idle */
908 #define UTSR0_RBB (1 << 3) /* Receiver begin break */
909 #define UTSR0_REB (1 << 4) /* Receiver end break */
910 #define UTSR0_EIF (1 << 5) /* Error in FIFO */
912 #define UTSR1_RNE (1 << 1) /* Receive FIFO not empty */
913 #define UTSR1_TNF (1 << 2) /* Transmit FIFO not full */
914 #define UTSR1_PRE (1 << 3) /* Parity error */
915 #define UTSR1_FRE (1 << 4) /* Frame error */
916 #define UTSR1_ROR (1 << 5) /* Receive Over Run */
918 #define RX_FIFO_PRE (1 << 8)
919 #define RX_FIFO_FRE (1 << 9)
920 #define RX_FIFO_ROR (1 << 10)
922 #define TYPE_STRONGARM_UART "strongarm-uart"
923 OBJECT_DECLARE_SIMPLE_TYPE(StrongARMUARTState
, STRONGARM_UART
)
925 struct StrongARMUARTState
{
926 SysBusDevice parent_obj
;
941 uint16_t rx_fifo
[12]; /* value + error flags in high bits */
945 uint64_t char_transmit_time
; /* time to transmit a char in nanoseconds */
947 QEMUTimer
*rx_timeout_timer
;
951 static void strongarm_uart_update_status(StrongARMUARTState
*s
)
955 if (s
->tx_len
!= 8) {
959 if (s
->rx_len
!= 0) {
960 uint16_t ent
= s
->rx_fifo
[s
->rx_start
];
963 if (ent
& RX_FIFO_PRE
) {
964 s
->utsr1
|= UTSR1_PRE
;
966 if (ent
& RX_FIFO_FRE
) {
967 s
->utsr1
|= UTSR1_FRE
;
969 if (ent
& RX_FIFO_ROR
) {
970 s
->utsr1
|= UTSR1_ROR
;
977 static void strongarm_uart_update_int_status(StrongARMUARTState
*s
)
979 uint16_t utsr0
= s
->utsr0
&
980 (UTSR0_REB
| UTSR0_RBB
| UTSR0_RID
);
983 if ((s
->utcr3
& UTCR3_TXE
) &&
984 (s
->utcr3
& UTCR3_TIE
) &&
989 if ((s
->utcr3
& UTCR3_RXE
) &&
990 (s
->utcr3
& UTCR3_RIE
) &&
995 for (i
= 0; i
< s
->rx_len
&& i
< 4; i
++)
996 if (s
->rx_fifo
[(s
->rx_start
+ i
) % 12] & ~0xff) {
1002 qemu_set_irq(s
->irq
, utsr0
);
1005 static void strongarm_uart_update_parameters(StrongARMUARTState
*s
)
1007 int speed
, parity
, data_bits
, stop_bits
, frame_size
;
1008 QEMUSerialSetParams ssp
;
1012 if (s
->utcr0
& UTCR0_PE
) {
1015 if (s
->utcr0
& UTCR0_OES
) {
1023 if (s
->utcr0
& UTCR0_SBS
) {
1029 data_bits
= (s
->utcr0
& UTCR0_DSS
) ? 8 : 7;
1030 frame_size
+= data_bits
+ stop_bits
;
1031 speed
= 3686400 / 16 / (s
->brd
+ 1);
1033 ssp
.parity
= parity
;
1034 ssp
.data_bits
= data_bits
;
1035 ssp
.stop_bits
= stop_bits
;
1036 s
->char_transmit_time
= (NANOSECONDS_PER_SECOND
/ speed
) * frame_size
;
1037 qemu_chr_fe_ioctl(&s
->chr
, CHR_IOCTL_SERIAL_SET_PARAMS
, &ssp
);
1039 trace_strongarm_uart_update_parameters((s
->chr
.chr
?
1040 s
->chr
.chr
->label
: "NULL") ?:
1048 static void strongarm_uart_rx_to(void *opaque
)
1050 StrongARMUARTState
*s
= opaque
;
1053 s
->utsr0
|= UTSR0_RID
;
1054 strongarm_uart_update_int_status(s
);
1058 static void strongarm_uart_rx_push(StrongARMUARTState
*s
, uint16_t c
)
1060 if ((s
->utcr3
& UTCR3_RXE
) == 0) {
1065 if (s
->wait_break_end
) {
1066 s
->utsr0
|= UTSR0_REB
;
1067 s
->wait_break_end
= false;
1070 if (s
->rx_len
< 12) {
1071 s
->rx_fifo
[(s
->rx_start
+ s
->rx_len
) % 12] = c
;
1074 s
->rx_fifo
[(s
->rx_start
+ 11) % 12] |= RX_FIFO_ROR
;
1077 static int strongarm_uart_can_receive(void *opaque
)
1079 StrongARMUARTState
*s
= opaque
;
1081 if (s
->rx_len
== 12) {
1084 /* It's best not to get more than 2/3 of RX FIFO, so advertise that much */
1085 if (s
->rx_len
< 8) {
1086 return 8 - s
->rx_len
;
1091 static void strongarm_uart_receive(void *opaque
, const uint8_t *buf
, int size
)
1093 StrongARMUARTState
*s
= opaque
;
1096 for (i
= 0; i
< size
; i
++) {
1097 strongarm_uart_rx_push(s
, buf
[i
]);
1100 /* call the timeout receive callback in 3 char transmit time */
1101 timer_mod(s
->rx_timeout_timer
,
1102 qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL
) + s
->char_transmit_time
* 3);
1104 strongarm_uart_update_status(s
);
1105 strongarm_uart_update_int_status(s
);
1108 static void strongarm_uart_event(void *opaque
, QEMUChrEvent event
)
1110 StrongARMUARTState
*s
= opaque
;
1111 if (event
== CHR_EVENT_BREAK
) {
1112 s
->utsr0
|= UTSR0_RBB
;
1113 strongarm_uart_rx_push(s
, RX_FIFO_FRE
);
1114 s
->wait_break_end
= true;
1115 strongarm_uart_update_status(s
);
1116 strongarm_uart_update_int_status(s
);
1120 static void strongarm_uart_tx(void *opaque
)
1122 StrongARMUARTState
*s
= opaque
;
1123 uint64_t new_xmit_ts
= qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL
);
1125 if (s
->utcr3
& UTCR3_LBM
) /* loopback */ {
1126 strongarm_uart_receive(s
, &s
->tx_fifo
[s
->tx_start
], 1);
1127 } else if (qemu_chr_fe_backend_connected(&s
->chr
)) {
1128 /* XXX this blocks entire thread. Rewrite to use
1129 * qemu_chr_fe_write and background I/O callbacks */
1130 qemu_chr_fe_write_all(&s
->chr
, &s
->tx_fifo
[s
->tx_start
], 1);
1133 s
->tx_start
= (s
->tx_start
+ 1) % 8;
1136 timer_mod(s
->tx_timer
, new_xmit_ts
+ s
->char_transmit_time
);
1138 strongarm_uart_update_status(s
);
1139 strongarm_uart_update_int_status(s
);
1142 static uint64_t strongarm_uart_read(void *opaque
, hwaddr addr
,
1145 StrongARMUARTState
*s
= opaque
;
1156 return s
->brd
& 0xff;
1162 if (s
->rx_len
!= 0) {
1163 ret
= s
->rx_fifo
[s
->rx_start
];
1164 s
->rx_start
= (s
->rx_start
+ 1) % 12;
1166 strongarm_uart_update_status(s
);
1167 strongarm_uart_update_int_status(s
);
1179 qemu_log_mask(LOG_GUEST_ERROR
,
1180 "%s: Bad uart register read 0x"HWADDR_FMT_plx
"\n",
1186 static void strongarm_uart_write(void *opaque
, hwaddr addr
,
1187 uint64_t value
, unsigned size
)
1189 StrongARMUARTState
*s
= opaque
;
1193 s
->utcr0
= value
& 0x7f;
1194 strongarm_uart_update_parameters(s
);
1198 s
->brd
= (s
->brd
& 0xff) | ((value
& 0xf) << 8);
1199 strongarm_uart_update_parameters(s
);
1203 s
->brd
= (s
->brd
& 0xf00) | (value
& 0xff);
1204 strongarm_uart_update_parameters(s
);
1208 s
->utcr3
= value
& 0x3f;
1209 if ((s
->utcr3
& UTCR3_RXE
) == 0) {
1212 if ((s
->utcr3
& UTCR3_TXE
) == 0) {
1215 strongarm_uart_update_status(s
);
1216 strongarm_uart_update_int_status(s
);
1220 if ((s
->utcr3
& UTCR3_TXE
) && s
->tx_len
!= 8) {
1221 s
->tx_fifo
[(s
->tx_start
+ s
->tx_len
) % 8] = value
;
1223 strongarm_uart_update_status(s
);
1224 strongarm_uart_update_int_status(s
);
1225 if (s
->tx_len
== 1) {
1226 strongarm_uart_tx(s
);
1232 s
->utsr0
= s
->utsr0
& ~(value
&
1233 (UTSR0_REB
| UTSR0_RBB
| UTSR0_RID
));
1234 strongarm_uart_update_int_status(s
);
1238 qemu_log_mask(LOG_GUEST_ERROR
,
1239 "%s: Bad uart register write 0x"HWADDR_FMT_plx
"\n",
1244 static const MemoryRegionOps strongarm_uart_ops
= {
1245 .read
= strongarm_uart_read
,
1246 .write
= strongarm_uart_write
,
1247 .endianness
= DEVICE_NATIVE_ENDIAN
,
1250 static void strongarm_uart_init(Object
*obj
)
1252 StrongARMUARTState
*s
= STRONGARM_UART(obj
);
1253 SysBusDevice
*dev
= SYS_BUS_DEVICE(obj
);
1255 memory_region_init_io(&s
->iomem
, obj
, &strongarm_uart_ops
, s
,
1257 sysbus_init_mmio(dev
, &s
->iomem
);
1258 sysbus_init_irq(dev
, &s
->irq
);
1261 static void strongarm_uart_realize(DeviceState
*dev
, Error
**errp
)
1263 StrongARMUARTState
*s
= STRONGARM_UART(dev
);
1265 s
->rx_timeout_timer
= timer_new_ns(QEMU_CLOCK_VIRTUAL
,
1266 strongarm_uart_rx_to
,
1268 s
->tx_timer
= timer_new_ns(QEMU_CLOCK_VIRTUAL
, strongarm_uart_tx
, s
);
1269 qemu_chr_fe_set_handlers(&s
->chr
,
1270 strongarm_uart_can_receive
,
1271 strongarm_uart_receive
,
1272 strongarm_uart_event
,
1273 NULL
, s
, NULL
, true);
1276 static void strongarm_uart_reset(DeviceState
*dev
)
1278 StrongARMUARTState
*s
= STRONGARM_UART(dev
);
1280 s
->utcr0
= UTCR0_DSS
; /* 8 data, no parity */
1281 s
->brd
= 23; /* 9600 */
1282 /* enable send & recv - this actually violates spec */
1283 s
->utcr3
= UTCR3_TXE
| UTCR3_RXE
;
1285 s
->rx_len
= s
->tx_len
= 0;
1287 strongarm_uart_update_parameters(s
);
1288 strongarm_uart_update_status(s
);
1289 strongarm_uart_update_int_status(s
);
1292 static int strongarm_uart_post_load(void *opaque
, int version_id
)
1294 StrongARMUARTState
*s
= opaque
;
1296 strongarm_uart_update_parameters(s
);
1297 strongarm_uart_update_status(s
);
1298 strongarm_uart_update_int_status(s
);
1300 /* tx and restart timer */
1302 strongarm_uart_tx(s
);
1305 /* restart rx timeout timer */
1307 timer_mod(s
->rx_timeout_timer
,
1308 qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL
) + s
->char_transmit_time
* 3);
1314 static const VMStateDescription vmstate_strongarm_uart_regs
= {
1315 .name
= "strongarm-uart",
1317 .minimum_version_id
= 0,
1318 .post_load
= strongarm_uart_post_load
,
1319 .fields
= (const VMStateField
[]) {
1320 VMSTATE_UINT8(utcr0
, StrongARMUARTState
),
1321 VMSTATE_UINT16(brd
, StrongARMUARTState
),
1322 VMSTATE_UINT8(utcr3
, StrongARMUARTState
),
1323 VMSTATE_UINT8(utsr0
, StrongARMUARTState
),
1324 VMSTATE_UINT8_ARRAY(tx_fifo
, StrongARMUARTState
, 8),
1325 VMSTATE_UINT8(tx_start
, StrongARMUARTState
),
1326 VMSTATE_UINT8(tx_len
, StrongARMUARTState
),
1327 VMSTATE_UINT16_ARRAY(rx_fifo
, StrongARMUARTState
, 12),
1328 VMSTATE_UINT8(rx_start
, StrongARMUARTState
),
1329 VMSTATE_UINT8(rx_len
, StrongARMUARTState
),
1330 VMSTATE_BOOL(wait_break_end
, StrongARMUARTState
),
1331 VMSTATE_END_OF_LIST(),
1335 static Property strongarm_uart_properties
[] = {
1336 DEFINE_PROP_CHR("chardev", StrongARMUARTState
, chr
),
1337 DEFINE_PROP_END_OF_LIST(),
1340 static void strongarm_uart_class_init(ObjectClass
*klass
, void *data
)
1342 DeviceClass
*dc
= DEVICE_CLASS(klass
);
1344 dc
->desc
= "StrongARM UART controller";
1345 device_class_set_legacy_reset(dc
, strongarm_uart_reset
);
1346 dc
->vmsd
= &vmstate_strongarm_uart_regs
;
1347 device_class_set_props(dc
, strongarm_uart_properties
);
1348 dc
->realize
= strongarm_uart_realize
;
1351 static const TypeInfo strongarm_uart_info
= {
1352 .name
= TYPE_STRONGARM_UART
,
1353 .parent
= TYPE_SYS_BUS_DEVICE
,
1354 .instance_size
= sizeof(StrongARMUARTState
),
1355 .instance_init
= strongarm_uart_init
,
1356 .class_init
= strongarm_uart_class_init
,
1359 /* Synchronous Serial Ports */
1361 #define TYPE_STRONGARM_SSP "strongarm-ssp"
1362 OBJECT_DECLARE_SIMPLE_TYPE(StrongARMSSPState
, STRONGARM_SSP
)
1364 struct StrongARMSSPState
{
1365 SysBusDevice parent_obj
;
1374 uint16_t rx_fifo
[8];
1379 #define SSCR0 0x60 /* SSP Control register 0 */
1380 #define SSCR1 0x64 /* SSP Control register 1 */
1381 #define SSDR 0x6c /* SSP Data register */
1382 #define SSSR 0x74 /* SSP Status register */
1384 /* Bitfields for above registers */
1385 #define SSCR0_SPI(x) (((x) & 0x30) == 0x00)
1386 #define SSCR0_SSP(x) (((x) & 0x30) == 0x10)
1387 #define SSCR0_UWIRE(x) (((x) & 0x30) == 0x20)
1388 #define SSCR0_PSP(x) (((x) & 0x30) == 0x30)
1389 #define SSCR0_SSE (1 << 7)
1390 #define SSCR0_DSS(x) (((x) & 0xf) + 1)
1391 #define SSCR1_RIE (1 << 0)
1392 #define SSCR1_TIE (1 << 1)
1393 #define SSCR1_LBM (1 << 2)
1394 #define SSSR_TNF (1 << 2)
1395 #define SSSR_RNE (1 << 3)
1396 #define SSSR_TFS (1 << 5)
1397 #define SSSR_RFS (1 << 6)
1398 #define SSSR_ROR (1 << 7)
1399 #define SSSR_RW 0x0080
1401 static void strongarm_ssp_int_update(StrongARMSSPState
*s
)
1405 level
|= (s
->sssr
& SSSR_ROR
);
1406 level
|= (s
->sssr
& SSSR_RFS
) && (s
->sscr
[1] & SSCR1_RIE
);
1407 level
|= (s
->sssr
& SSSR_TFS
) && (s
->sscr
[1] & SSCR1_TIE
);
1408 qemu_set_irq(s
->irq
, level
);
1411 static void strongarm_ssp_fifo_update(StrongARMSSPState
*s
)
1413 s
->sssr
&= ~SSSR_TFS
;
1414 s
->sssr
&= ~SSSR_TNF
;
1415 if (s
->sscr
[0] & SSCR0_SSE
) {
1416 if (s
->rx_level
>= 4) {
1417 s
->sssr
|= SSSR_RFS
;
1419 s
->sssr
&= ~SSSR_RFS
;
1422 s
->sssr
|= SSSR_RNE
;
1424 s
->sssr
&= ~SSSR_RNE
;
1426 /* TX FIFO is never filled, so it is always in underrun
1427 condition if SSP is enabled */
1428 s
->sssr
|= SSSR_TFS
;
1429 s
->sssr
|= SSSR_TNF
;
1432 strongarm_ssp_int_update(s
);
1435 static uint64_t strongarm_ssp_read(void *opaque
, hwaddr addr
,
1438 StrongARMSSPState
*s
= opaque
;
1449 if (~s
->sscr
[0] & SSCR0_SSE
) {
1452 if (s
->rx_level
< 1) {
1453 trace_strongarm_ssp_read_underrun();
1457 retval
= s
->rx_fifo
[s
->rx_start
++];
1459 strongarm_ssp_fifo_update(s
);
1462 qemu_log_mask(LOG_GUEST_ERROR
,
1463 "%s: Bad ssp register read 0x"HWADDR_FMT_plx
"\n",
1470 static void strongarm_ssp_write(void *opaque
, hwaddr addr
,
1471 uint64_t value
, unsigned size
)
1473 StrongARMSSPState
*s
= opaque
;
1477 s
->sscr
[0] = value
& 0xffbf;
1478 if ((s
->sscr
[0] & SSCR0_SSE
) && SSCR0_DSS(value
) < 4) {
1479 qemu_log_mask(LOG_GUEST_ERROR
, "%s: Wrong data size: %i bits\n",
1480 __func__
, (int)SSCR0_DSS(value
));
1482 if (!(value
& SSCR0_SSE
)) {
1486 strongarm_ssp_fifo_update(s
);
1490 s
->sscr
[1] = value
& 0x2f;
1491 if (value
& SSCR1_LBM
) {
1492 qemu_log_mask(LOG_GUEST_ERROR
,
1493 "%s: Attempt to use SSP LBM mode\n",
1496 strongarm_ssp_fifo_update(s
);
1500 s
->sssr
&= ~(value
& SSSR_RW
);
1501 strongarm_ssp_int_update(s
);
1505 if (SSCR0_UWIRE(s
->sscr
[0])) {
1508 /* Note how 32bits overflow does no harm here */
1509 value
&= (1 << SSCR0_DSS(s
->sscr
[0])) - 1;
1511 /* Data goes from here to the Tx FIFO and is shifted out from
1512 * there directly to the slave, no need to buffer it.
1514 if (s
->sscr
[0] & SSCR0_SSE
) {
1516 if (s
->sscr
[1] & SSCR1_LBM
) {
1519 readval
= ssi_transfer(s
->bus
, value
);
1522 if (s
->rx_level
< 0x08) {
1523 s
->rx_fifo
[(s
->rx_start
+ s
->rx_level
++) & 0x7] = readval
;
1525 s
->sssr
|= SSSR_ROR
;
1528 strongarm_ssp_fifo_update(s
);
1532 qemu_log_mask(LOG_GUEST_ERROR
,
1533 "%s: Bad ssp register write 0x"HWADDR_FMT_plx
"\n",
1539 static const MemoryRegionOps strongarm_ssp_ops
= {
1540 .read
= strongarm_ssp_read
,
1541 .write
= strongarm_ssp_write
,
1542 .endianness
= DEVICE_NATIVE_ENDIAN
,
1545 static int strongarm_ssp_post_load(void *opaque
, int version_id
)
1547 StrongARMSSPState
*s
= opaque
;
1549 strongarm_ssp_fifo_update(s
);
1554 static void strongarm_ssp_init(Object
*obj
)
1556 SysBusDevice
*sbd
= SYS_BUS_DEVICE(obj
);
1557 DeviceState
*dev
= DEVICE(sbd
);
1558 StrongARMSSPState
*s
= STRONGARM_SSP(dev
);
1560 sysbus_init_irq(sbd
, &s
->irq
);
1562 memory_region_init_io(&s
->iomem
, obj
, &strongarm_ssp_ops
, s
,
1564 sysbus_init_mmio(sbd
, &s
->iomem
);
1566 s
->bus
= ssi_create_bus(dev
, "ssi");
1569 static void strongarm_ssp_reset(DeviceState
*dev
)
1571 StrongARMSSPState
*s
= STRONGARM_SSP(dev
);
1573 s
->sssr
= 0x03; /* 3 bit data, SPI, disabled */
1578 static const VMStateDescription vmstate_strongarm_ssp_regs
= {
1579 .name
= "strongarm-ssp",
1581 .minimum_version_id
= 0,
1582 .post_load
= strongarm_ssp_post_load
,
1583 .fields
= (const VMStateField
[]) {
1584 VMSTATE_UINT16_ARRAY(sscr
, StrongARMSSPState
, 2),
1585 VMSTATE_UINT16(sssr
, StrongARMSSPState
),
1586 VMSTATE_UINT16_ARRAY(rx_fifo
, StrongARMSSPState
, 8),
1587 VMSTATE_UINT8(rx_start
, StrongARMSSPState
),
1588 VMSTATE_UINT8(rx_level
, StrongARMSSPState
),
1589 VMSTATE_END_OF_LIST(),
1593 static void strongarm_ssp_class_init(ObjectClass
*klass
, void *data
)
1595 DeviceClass
*dc
= DEVICE_CLASS(klass
);
1597 dc
->desc
= "StrongARM SSP controller";
1598 device_class_set_legacy_reset(dc
, strongarm_ssp_reset
);
1599 dc
->vmsd
= &vmstate_strongarm_ssp_regs
;
1602 static const TypeInfo strongarm_ssp_info
= {
1603 .name
= TYPE_STRONGARM_SSP
,
1604 .parent
= TYPE_SYS_BUS_DEVICE
,
1605 .instance_size
= sizeof(StrongARMSSPState
),
1606 .instance_init
= strongarm_ssp_init
,
1607 .class_init
= strongarm_ssp_class_init
,
1610 /* Main CPU functions */
1611 StrongARMState
*sa1110_init(const char *cpu_type
)
1616 s
= g_new0(StrongARMState
, 1);
1618 if (strncmp(cpu_type
, "sa1110", 6)) {
1619 error_report("Machine requires a SA1110 processor.");
1623 s
->cpu
= ARM_CPU(cpu_create(cpu_type
));
1625 s
->pic
= sysbus_create_varargs("strongarm_pic", 0x90050000,
1626 qdev_get_gpio_in(DEVICE(s
->cpu
), ARM_CPU_IRQ
),
1627 qdev_get_gpio_in(DEVICE(s
->cpu
), ARM_CPU_FIQ
),
1630 sysbus_create_varargs("pxa25x-timer", 0x90000000,
1631 qdev_get_gpio_in(s
->pic
, SA_PIC_OSTC0
),
1632 qdev_get_gpio_in(s
->pic
, SA_PIC_OSTC1
),
1633 qdev_get_gpio_in(s
->pic
, SA_PIC_OSTC2
),
1634 qdev_get_gpio_in(s
->pic
, SA_PIC_OSTC3
),
1637 sysbus_create_simple(TYPE_STRONGARM_RTC
, 0x90010000,
1638 qdev_get_gpio_in(s
->pic
, SA_PIC_RTC_ALARM
));
1640 s
->gpio
= strongarm_gpio_init(0x90040000, s
->pic
);
1642 s
->ppc
= sysbus_create_varargs(TYPE_STRONGARM_PPC
, 0x90060000, NULL
);
1644 for (i
= 0; sa_serial
[i
].io_base
; i
++) {
1645 DeviceState
*dev
= qdev_new(TYPE_STRONGARM_UART
);
1646 qdev_prop_set_chr(dev
, "chardev", serial_hd(i
));
1647 sysbus_realize_and_unref(SYS_BUS_DEVICE(dev
), &error_fatal
);
1648 sysbus_mmio_map(SYS_BUS_DEVICE(dev
), 0,
1649 sa_serial
[i
].io_base
);
1650 sysbus_connect_irq(SYS_BUS_DEVICE(dev
), 0,
1651 qdev_get_gpio_in(s
->pic
, sa_serial
[i
].irq
));
1654 s
->ssp
= sysbus_create_varargs(TYPE_STRONGARM_SSP
, 0x80070000,
1655 qdev_get_gpio_in(s
->pic
, SA_PIC_SSP
), NULL
);
1656 s
->ssp_bus
= (SSIBus
*)qdev_get_child_bus(s
->ssp
, "ssi");
1661 static void strongarm_register_types(void)
1663 type_register_static(&strongarm_pic_info
);
1664 type_register_static(&strongarm_rtc_sysbus_info
);
1665 type_register_static(&strongarm_gpio_info
);
1666 type_register_static(&strongarm_ppc_info
);
1667 type_register_static(&strongarm_uart_info
);
1668 type_register_static(&strongarm_ssp_info
);
1671 type_init(strongarm_register_types
)