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/boards.h"
33 #include "hw/sysbus.h"
34 #include "strongarm.h"
35 #include "qemu/error-report.h"
36 #include "hw/arm/arm.h"
37 #include "chardev/char-fe.h"
38 #include "chardev/char-serial.h"
39 #include "sysemu/sysemu.h"
40 #include "hw/ssi/ssi.h"
41 #include "qemu/cutils.h"
48 - Implement cp15, c14 ?
49 - Implement cp15, c15 !!! (idle used in L)
50 - Implement idle mode handling/DIM
51 - Implement sleep mode/Wake sources
52 - Implement reset control
53 - Implement memory control regs
55 - Maybe support MBGNT/MBREQ
60 - Enhance UART with modem signals
64 # define DPRINTF(format, ...) printf(format , ## __VA_ARGS__)
66 # define DPRINTF(format, ...) do { } while (0)
73 { 0x80010000, SA_PIC_UART1
},
74 { 0x80030000, SA_PIC_UART2
},
75 { 0x80050000, SA_PIC_UART3
},
79 /* Interrupt Controller */
81 #define TYPE_STRONGARM_PIC "strongarm_pic"
82 #define STRONGARM_PIC(obj) \
83 OBJECT_CHECK(StrongARMPICState, (obj), TYPE_STRONGARM_PIC)
85 typedef struct StrongARMPICState
{
86 SysBusDevice parent_obj
;
105 #define SA_PIC_SRCS 32
108 static void strongarm_pic_update(void *opaque
)
110 StrongARMPICState
*s
= opaque
;
112 /* FIXME: reflect DIM */
113 qemu_set_irq(s
->fiq
, s
->pending
& s
->enabled
& s
->is_fiq
);
114 qemu_set_irq(s
->irq
, s
->pending
& s
->enabled
& ~s
->is_fiq
);
117 static void strongarm_pic_set_irq(void *opaque
, int irq
, int level
)
119 StrongARMPICState
*s
= opaque
;
122 s
->pending
|= 1 << irq
;
124 s
->pending
&= ~(1 << irq
);
127 strongarm_pic_update(s
);
130 static uint64_t strongarm_pic_mem_read(void *opaque
, hwaddr offset
,
133 StrongARMPICState
*s
= opaque
;
137 return s
->pending
& ~s
->is_fiq
& s
->enabled
;
143 return s
->int_idle
== 0;
145 return s
->pending
& s
->is_fiq
& s
->enabled
;
149 printf("%s: Bad register offset 0x" TARGET_FMT_plx
"\n",
155 static void strongarm_pic_mem_write(void *opaque
, hwaddr offset
,
156 uint64_t value
, unsigned size
)
158 StrongARMPICState
*s
= opaque
;
168 s
->int_idle
= (value
& 1) ? 0 : ~0;
171 printf("%s: Bad register offset 0x" TARGET_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 VMStateDescription vmstate_strongarm_pic_regs
= {
205 .name
= "strongarm_pic",
207 .minimum_version_id
= 0,
208 .post_load
= strongarm_pic_post_load
,
209 .fields
= (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 #define STRONGARM_RTC(obj) \
251 OBJECT_CHECK(StrongARMRTCState, (obj), TYPE_STRONGARM_RTC)
253 typedef struct StrongARMRTCState
{
254 SysBusDevice parent_obj
;
262 QEMUTimer
*rtc_alarm
;
268 static inline void strongarm_rtc_int_update(StrongARMRTCState
*s
)
270 qemu_set_irq(s
->rtc_irq
, s
->rtsr
& RTSR_AL
);
271 qemu_set_irq(s
->rtc_hz_irq
, s
->rtsr
& RTSR_HZ
);
274 static void strongarm_rtc_hzupdate(StrongARMRTCState
*s
)
276 int64_t rt
= qemu_clock_get_ms(rtc_clock
);
277 s
->last_rcnr
+= ((rt
- s
->last_hz
) << 15) /
278 (1000 * ((s
->rttr
& 0xffff) + 1));
282 static inline void strongarm_rtc_timer_update(StrongARMRTCState
*s
)
284 if ((s
->rtsr
& RTSR_HZE
) && !(s
->rtsr
& RTSR_HZ
)) {
285 timer_mod(s
->rtc_hz
, s
->last_hz
+ 1000);
287 timer_del(s
->rtc_hz
);
290 if ((s
->rtsr
& RTSR_ALE
) && !(s
->rtsr
& RTSR_AL
)) {
291 timer_mod(s
->rtc_alarm
, s
->last_hz
+
292 (((s
->rtar
- s
->last_rcnr
) * 1000 *
293 ((s
->rttr
& 0xffff) + 1)) >> 15));
295 timer_del(s
->rtc_alarm
);
299 static inline void strongarm_rtc_alarm_tick(void *opaque
)
301 StrongARMRTCState
*s
= opaque
;
303 strongarm_rtc_timer_update(s
);
304 strongarm_rtc_int_update(s
);
307 static inline void strongarm_rtc_hz_tick(void *opaque
)
309 StrongARMRTCState
*s
= opaque
;
311 strongarm_rtc_timer_update(s
);
312 strongarm_rtc_int_update(s
);
315 static uint64_t strongarm_rtc_read(void *opaque
, hwaddr addr
,
318 StrongARMRTCState
*s
= opaque
;
328 return s
->last_rcnr
+
329 ((qemu_clock_get_ms(rtc_clock
) - s
->last_hz
) << 15) /
330 (1000 * ((s
->rttr
& 0xffff) + 1));
332 printf("%s: Bad register 0x" TARGET_FMT_plx
"\n", __func__
, addr
);
337 static void strongarm_rtc_write(void *opaque
, hwaddr addr
,
338 uint64_t value
, unsigned size
)
340 StrongARMRTCState
*s
= opaque
;
345 strongarm_rtc_hzupdate(s
);
347 strongarm_rtc_timer_update(s
);
352 s
->rtsr
= (value
& (RTSR_ALE
| RTSR_HZE
)) |
353 (s
->rtsr
& ~(value
& (RTSR_AL
| RTSR_HZ
)));
355 if (s
->rtsr
!= old_rtsr
) {
356 strongarm_rtc_timer_update(s
);
359 strongarm_rtc_int_update(s
);
364 strongarm_rtc_timer_update(s
);
368 strongarm_rtc_hzupdate(s
);
369 s
->last_rcnr
= value
;
370 strongarm_rtc_timer_update(s
);
374 printf("%s: Bad register 0x" TARGET_FMT_plx
"\n", __func__
, addr
);
378 static const MemoryRegionOps strongarm_rtc_ops
= {
379 .read
= strongarm_rtc_read
,
380 .write
= strongarm_rtc_write
,
381 .endianness
= DEVICE_NATIVE_ENDIAN
,
384 static void strongarm_rtc_init(Object
*obj
)
386 StrongARMRTCState
*s
= STRONGARM_RTC(obj
);
387 SysBusDevice
*dev
= SYS_BUS_DEVICE(obj
);
393 qemu_get_timedate(&tm
, 0);
395 s
->last_rcnr
= (uint32_t) mktimegm(&tm
);
396 s
->last_hz
= qemu_clock_get_ms(rtc_clock
);
398 s
->rtc_alarm
= timer_new_ms(rtc_clock
, strongarm_rtc_alarm_tick
, s
);
399 s
->rtc_hz
= timer_new_ms(rtc_clock
, strongarm_rtc_hz_tick
, s
);
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_pre_save(void *opaque
)
411 StrongARMRTCState
*s
= opaque
;
413 strongarm_rtc_hzupdate(s
);
416 static int strongarm_rtc_post_load(void *opaque
, int version_id
)
418 StrongARMRTCState
*s
= opaque
;
420 strongarm_rtc_timer_update(s
);
421 strongarm_rtc_int_update(s
);
426 static const VMStateDescription vmstate_strongarm_rtc_regs
= {
427 .name
= "strongarm-rtc",
429 .minimum_version_id
= 0,
430 .pre_save
= strongarm_rtc_pre_save
,
431 .post_load
= strongarm_rtc_post_load
,
432 .fields
= (VMStateField
[]) {
433 VMSTATE_UINT32(rttr
, StrongARMRTCState
),
434 VMSTATE_UINT32(rtsr
, StrongARMRTCState
),
435 VMSTATE_UINT32(rtar
, StrongARMRTCState
),
436 VMSTATE_UINT32(last_rcnr
, StrongARMRTCState
),
437 VMSTATE_INT64(last_hz
, StrongARMRTCState
),
438 VMSTATE_END_OF_LIST(),
442 static void strongarm_rtc_sysbus_class_init(ObjectClass
*klass
, void *data
)
444 DeviceClass
*dc
= DEVICE_CLASS(klass
);
446 dc
->desc
= "StrongARM RTC Controller";
447 dc
->vmsd
= &vmstate_strongarm_rtc_regs
;
450 static const TypeInfo strongarm_rtc_sysbus_info
= {
451 .name
= TYPE_STRONGARM_RTC
,
452 .parent
= TYPE_SYS_BUS_DEVICE
,
453 .instance_size
= sizeof(StrongARMRTCState
),
454 .instance_init
= strongarm_rtc_init
,
455 .class_init
= strongarm_rtc_sysbus_class_init
,
468 #define TYPE_STRONGARM_GPIO "strongarm-gpio"
469 #define STRONGARM_GPIO(obj) \
470 OBJECT_CHECK(StrongARMGPIOInfo, (obj), TYPE_STRONGARM_GPIO)
472 typedef struct StrongARMGPIOInfo StrongARMGPIOInfo
;
473 struct StrongARMGPIOInfo
{
476 qemu_irq handler
[28];
492 static void strongarm_gpio_irq_update(StrongARMGPIOInfo
*s
)
495 for (i
= 0; i
< 11; i
++) {
496 qemu_set_irq(s
->irqs
[i
], s
->status
& (1 << i
));
499 qemu_set_irq(s
->irqX
, (s
->status
& ~0x7ff));
502 static void strongarm_gpio_set(void *opaque
, int line
, int level
)
504 StrongARMGPIOInfo
*s
= opaque
;
510 s
->status
|= s
->rising
& mask
&
511 ~s
->ilevel
& ~s
->dir
;
514 s
->status
|= s
->falling
& mask
&
519 if (s
->status
& mask
) {
520 strongarm_gpio_irq_update(s
);
524 static void strongarm_gpio_handler_update(StrongARMGPIOInfo
*s
)
526 uint32_t level
, diff
;
529 level
= s
->olevel
& s
->dir
;
531 for (diff
= s
->prev_level
^ level
; diff
; diff
^= 1 << bit
) {
533 qemu_set_irq(s
->handler
[bit
], (level
>> bit
) & 1);
536 s
->prev_level
= level
;
539 static uint64_t strongarm_gpio_read(void *opaque
, hwaddr offset
,
542 StrongARMGPIOInfo
*s
= opaque
;
545 case GPDR
: /* GPIO Pin-Direction registers */
548 case GPSR
: /* GPIO Pin-Output Set registers */
549 qemu_log_mask(LOG_GUEST_ERROR
,
550 "strongarm GPIO: read from write only register GPSR\n");
553 case GPCR
: /* GPIO Pin-Output Clear registers */
554 qemu_log_mask(LOG_GUEST_ERROR
,
555 "strongarm GPIO: read from write only register GPCR\n");
558 case GRER
: /* GPIO Rising-Edge Detect Enable registers */
561 case GFER
: /* GPIO Falling-Edge Detect Enable registers */
564 case GAFR
: /* GPIO Alternate Function registers */
567 case GPLR
: /* GPIO Pin-Level registers */
568 return (s
->olevel
& s
->dir
) |
569 (s
->ilevel
& ~s
->dir
);
571 case GEDR
: /* GPIO Edge Detect Status registers */
575 printf("%s: Bad offset 0x" TARGET_FMT_plx
"\n", __func__
, offset
);
581 static void strongarm_gpio_write(void *opaque
, hwaddr offset
,
582 uint64_t value
, unsigned size
)
584 StrongARMGPIOInfo
*s
= opaque
;
587 case GPDR
: /* GPIO Pin-Direction registers */
589 strongarm_gpio_handler_update(s
);
592 case GPSR
: /* GPIO Pin-Output Set registers */
594 strongarm_gpio_handler_update(s
);
597 case GPCR
: /* GPIO Pin-Output Clear registers */
599 strongarm_gpio_handler_update(s
);
602 case GRER
: /* GPIO Rising-Edge Detect Enable registers */
606 case GFER
: /* GPIO Falling-Edge Detect Enable registers */
610 case GAFR
: /* GPIO Alternate Function registers */
614 case GEDR
: /* GPIO Edge Detect Status registers */
616 strongarm_gpio_irq_update(s
);
620 printf("%s: Bad offset 0x" TARGET_FMT_plx
"\n", __func__
, offset
);
624 static const MemoryRegionOps strongarm_gpio_ops
= {
625 .read
= strongarm_gpio_read
,
626 .write
= strongarm_gpio_write
,
627 .endianness
= DEVICE_NATIVE_ENDIAN
,
630 static DeviceState
*strongarm_gpio_init(hwaddr base
,
636 dev
= qdev_create(NULL
, TYPE_STRONGARM_GPIO
);
637 qdev_init_nofail(dev
);
639 sysbus_mmio_map(SYS_BUS_DEVICE(dev
), 0, base
);
640 for (i
= 0; i
< 12; i
++)
641 sysbus_connect_irq(SYS_BUS_DEVICE(dev
), i
,
642 qdev_get_gpio_in(pic
, SA_PIC_GPIO0_EDGE
+ i
));
647 static void strongarm_gpio_initfn(Object
*obj
)
649 DeviceState
*dev
= DEVICE(obj
);
650 StrongARMGPIOInfo
*s
= STRONGARM_GPIO(obj
);
651 SysBusDevice
*sbd
= SYS_BUS_DEVICE(obj
);
654 qdev_init_gpio_in(dev
, strongarm_gpio_set
, 28);
655 qdev_init_gpio_out(dev
, s
->handler
, 28);
657 memory_region_init_io(&s
->iomem
, obj
, &strongarm_gpio_ops
, s
,
660 sysbus_init_mmio(sbd
, &s
->iomem
);
661 for (i
= 0; i
< 11; i
++) {
662 sysbus_init_irq(sbd
, &s
->irqs
[i
]);
664 sysbus_init_irq(sbd
, &s
->irqX
);
667 static const VMStateDescription vmstate_strongarm_gpio_regs
= {
668 .name
= "strongarm-gpio",
670 .minimum_version_id
= 0,
671 .fields
= (VMStateField
[]) {
672 VMSTATE_UINT32(ilevel
, StrongARMGPIOInfo
),
673 VMSTATE_UINT32(olevel
, StrongARMGPIOInfo
),
674 VMSTATE_UINT32(dir
, StrongARMGPIOInfo
),
675 VMSTATE_UINT32(rising
, StrongARMGPIOInfo
),
676 VMSTATE_UINT32(falling
, StrongARMGPIOInfo
),
677 VMSTATE_UINT32(status
, StrongARMGPIOInfo
),
678 VMSTATE_UINT32(gafr
, StrongARMGPIOInfo
),
679 VMSTATE_UINT32(prev_level
, StrongARMGPIOInfo
),
680 VMSTATE_END_OF_LIST(),
684 static void strongarm_gpio_class_init(ObjectClass
*klass
, void *data
)
686 DeviceClass
*dc
= DEVICE_CLASS(klass
);
688 dc
->desc
= "StrongARM GPIO controller";
689 dc
->vmsd
= &vmstate_strongarm_gpio_regs
;
692 static const TypeInfo strongarm_gpio_info
= {
693 .name
= TYPE_STRONGARM_GPIO
,
694 .parent
= TYPE_SYS_BUS_DEVICE
,
695 .instance_size
= sizeof(StrongARMGPIOInfo
),
696 .instance_init
= strongarm_gpio_initfn
,
697 .class_init
= strongarm_gpio_class_init
,
700 /* Peripheral Pin Controller */
707 #define TYPE_STRONGARM_PPC "strongarm-ppc"
708 #define STRONGARM_PPC(obj) \
709 OBJECT_CHECK(StrongARMPPCInfo, (obj), TYPE_STRONGARM_PPC)
711 typedef struct StrongARMPPCInfo StrongARMPPCInfo
;
712 struct StrongARMPPCInfo
{
713 SysBusDevice parent_obj
;
716 qemu_irq handler
[28];
728 static void strongarm_ppc_set(void *opaque
, int line
, int level
)
730 StrongARMPPCInfo
*s
= opaque
;
733 s
->ilevel
|= 1 << line
;
735 s
->ilevel
&= ~(1 << line
);
739 static void strongarm_ppc_handler_update(StrongARMPPCInfo
*s
)
741 uint32_t level
, diff
;
744 level
= s
->olevel
& s
->dir
;
746 for (diff
= s
->prev_level
^ level
; diff
; diff
^= 1 << bit
) {
748 qemu_set_irq(s
->handler
[bit
], (level
>> bit
) & 1);
751 s
->prev_level
= level
;
754 static uint64_t strongarm_ppc_read(void *opaque
, hwaddr offset
,
757 StrongARMPPCInfo
*s
= opaque
;
760 case PPDR
: /* PPC Pin Direction registers */
761 return s
->dir
| ~0x3fffff;
763 case PPSR
: /* PPC Pin State registers */
764 return (s
->olevel
& s
->dir
) |
765 (s
->ilevel
& ~s
->dir
) |
769 return s
->ppar
| ~0x41000;
775 return s
->ppfr
| ~0x7f001;
778 printf("%s: Bad offset 0x" TARGET_FMT_plx
"\n", __func__
, offset
);
784 static void strongarm_ppc_write(void *opaque
, hwaddr offset
,
785 uint64_t value
, unsigned size
)
787 StrongARMPPCInfo
*s
= opaque
;
790 case PPDR
: /* PPC Pin Direction registers */
791 s
->dir
= value
& 0x3fffff;
792 strongarm_ppc_handler_update(s
);
795 case PPSR
: /* PPC Pin State registers */
796 s
->olevel
= value
& s
->dir
& 0x3fffff;
797 strongarm_ppc_handler_update(s
);
801 s
->ppar
= value
& 0x41000;
805 s
->psdr
= value
& 0x3fffff;
809 s
->ppfr
= value
& 0x7f001;
813 printf("%s: Bad offset 0x" TARGET_FMT_plx
"\n", __func__
, offset
);
817 static const MemoryRegionOps strongarm_ppc_ops
= {
818 .read
= strongarm_ppc_read
,
819 .write
= strongarm_ppc_write
,
820 .endianness
= DEVICE_NATIVE_ENDIAN
,
823 static void strongarm_ppc_init(Object
*obj
)
825 DeviceState
*dev
= DEVICE(obj
);
826 StrongARMPPCInfo
*s
= STRONGARM_PPC(obj
);
827 SysBusDevice
*sbd
= SYS_BUS_DEVICE(obj
);
829 qdev_init_gpio_in(dev
, strongarm_ppc_set
, 22);
830 qdev_init_gpio_out(dev
, s
->handler
, 22);
832 memory_region_init_io(&s
->iomem
, obj
, &strongarm_ppc_ops
, s
,
835 sysbus_init_mmio(sbd
, &s
->iomem
);
838 static const VMStateDescription vmstate_strongarm_ppc_regs
= {
839 .name
= "strongarm-ppc",
841 .minimum_version_id
= 0,
842 .fields
= (VMStateField
[]) {
843 VMSTATE_UINT32(ilevel
, StrongARMPPCInfo
),
844 VMSTATE_UINT32(olevel
, StrongARMPPCInfo
),
845 VMSTATE_UINT32(dir
, StrongARMPPCInfo
),
846 VMSTATE_UINT32(ppar
, StrongARMPPCInfo
),
847 VMSTATE_UINT32(psdr
, StrongARMPPCInfo
),
848 VMSTATE_UINT32(ppfr
, StrongARMPPCInfo
),
849 VMSTATE_UINT32(prev_level
, StrongARMPPCInfo
),
850 VMSTATE_END_OF_LIST(),
854 static void strongarm_ppc_class_init(ObjectClass
*klass
, void *data
)
856 DeviceClass
*dc
= DEVICE_CLASS(klass
);
858 dc
->desc
= "StrongARM PPC controller";
859 dc
->vmsd
= &vmstate_strongarm_ppc_regs
;
862 static const TypeInfo strongarm_ppc_info
= {
863 .name
= TYPE_STRONGARM_PPC
,
864 .parent
= TYPE_SYS_BUS_DEVICE
,
865 .instance_size
= sizeof(StrongARMPPCInfo
),
866 .instance_init
= strongarm_ppc_init
,
867 .class_init
= strongarm_ppc_class_init
,
879 #define UTCR0_PE (1 << 0) /* Parity enable */
880 #define UTCR0_OES (1 << 1) /* Even parity */
881 #define UTCR0_SBS (1 << 2) /* 2 stop bits */
882 #define UTCR0_DSS (1 << 3) /* 8-bit data */
884 #define UTCR3_RXE (1 << 0) /* Rx enable */
885 #define UTCR3_TXE (1 << 1) /* Tx enable */
886 #define UTCR3_BRK (1 << 2) /* Force Break */
887 #define UTCR3_RIE (1 << 3) /* Rx int enable */
888 #define UTCR3_TIE (1 << 4) /* Tx int enable */
889 #define UTCR3_LBM (1 << 5) /* Loopback */
891 #define UTSR0_TFS (1 << 0) /* Tx FIFO nearly empty */
892 #define UTSR0_RFS (1 << 1) /* Rx FIFO nearly full */
893 #define UTSR0_RID (1 << 2) /* Receiver Idle */
894 #define UTSR0_RBB (1 << 3) /* Receiver begin break */
895 #define UTSR0_REB (1 << 4) /* Receiver end break */
896 #define UTSR0_EIF (1 << 5) /* Error in FIFO */
898 #define UTSR1_RNE (1 << 1) /* Receive FIFO not empty */
899 #define UTSR1_TNF (1 << 2) /* Transmit FIFO not full */
900 #define UTSR1_PRE (1 << 3) /* Parity error */
901 #define UTSR1_FRE (1 << 4) /* Frame error */
902 #define UTSR1_ROR (1 << 5) /* Receive Over Run */
904 #define RX_FIFO_PRE (1 << 8)
905 #define RX_FIFO_FRE (1 << 9)
906 #define RX_FIFO_ROR (1 << 10)
908 #define TYPE_STRONGARM_UART "strongarm-uart"
909 #define STRONGARM_UART(obj) \
910 OBJECT_CHECK(StrongARMUARTState, (obj), TYPE_STRONGARM_UART)
912 typedef struct StrongARMUARTState
{
913 SysBusDevice parent_obj
;
928 uint16_t rx_fifo
[12]; /* value + error flags in high bits */
932 uint64_t char_transmit_time
; /* time to transmit a char in ticks*/
934 QEMUTimer
*rx_timeout_timer
;
936 } StrongARMUARTState
;
938 static void strongarm_uart_update_status(StrongARMUARTState
*s
)
942 if (s
->tx_len
!= 8) {
946 if (s
->rx_len
!= 0) {
947 uint16_t ent
= s
->rx_fifo
[s
->rx_start
];
950 if (ent
& RX_FIFO_PRE
) {
951 s
->utsr1
|= UTSR1_PRE
;
953 if (ent
& RX_FIFO_FRE
) {
954 s
->utsr1
|= UTSR1_FRE
;
956 if (ent
& RX_FIFO_ROR
) {
957 s
->utsr1
|= UTSR1_ROR
;
964 static void strongarm_uart_update_int_status(StrongARMUARTState
*s
)
966 uint16_t utsr0
= s
->utsr0
&
967 (UTSR0_REB
| UTSR0_RBB
| UTSR0_RID
);
970 if ((s
->utcr3
& UTCR3_TXE
) &&
971 (s
->utcr3
& UTCR3_TIE
) &&
976 if ((s
->utcr3
& UTCR3_RXE
) &&
977 (s
->utcr3
& UTCR3_RIE
) &&
982 for (i
= 0; i
< s
->rx_len
&& i
< 4; i
++)
983 if (s
->rx_fifo
[(s
->rx_start
+ i
) % 12] & ~0xff) {
989 qemu_set_irq(s
->irq
, utsr0
);
992 static void strongarm_uart_update_parameters(StrongARMUARTState
*s
)
994 int speed
, parity
, data_bits
, stop_bits
, frame_size
;
995 QEMUSerialSetParams ssp
;
999 if (s
->utcr0
& UTCR0_PE
) {
1002 if (s
->utcr0
& UTCR0_OES
) {
1010 if (s
->utcr0
& UTCR0_SBS
) {
1016 data_bits
= (s
->utcr0
& UTCR0_DSS
) ? 8 : 7;
1017 frame_size
+= data_bits
+ stop_bits
;
1018 speed
= 3686400 / 16 / (s
->brd
+ 1);
1020 ssp
.parity
= parity
;
1021 ssp
.data_bits
= data_bits
;
1022 ssp
.stop_bits
= stop_bits
;
1023 s
->char_transmit_time
= (NANOSECONDS_PER_SECOND
/ speed
) * frame_size
;
1024 qemu_chr_fe_ioctl(&s
->chr
, CHR_IOCTL_SERIAL_SET_PARAMS
, &ssp
);
1026 DPRINTF(stderr
, "%s speed=%d parity=%c data=%d stop=%d\n", s
->chr
->label
,
1027 speed
, parity
, data_bits
, stop_bits
);
1030 static void strongarm_uart_rx_to(void *opaque
)
1032 StrongARMUARTState
*s
= opaque
;
1035 s
->utsr0
|= UTSR0_RID
;
1036 strongarm_uart_update_int_status(s
);
1040 static void strongarm_uart_rx_push(StrongARMUARTState
*s
, uint16_t c
)
1042 if ((s
->utcr3
& UTCR3_RXE
) == 0) {
1047 if (s
->wait_break_end
) {
1048 s
->utsr0
|= UTSR0_REB
;
1049 s
->wait_break_end
= false;
1052 if (s
->rx_len
< 12) {
1053 s
->rx_fifo
[(s
->rx_start
+ s
->rx_len
) % 12] = c
;
1056 s
->rx_fifo
[(s
->rx_start
+ 11) % 12] |= RX_FIFO_ROR
;
1059 static int strongarm_uart_can_receive(void *opaque
)
1061 StrongARMUARTState
*s
= opaque
;
1063 if (s
->rx_len
== 12) {
1066 /* It's best not to get more than 2/3 of RX FIFO, so advertise that much */
1067 if (s
->rx_len
< 8) {
1068 return 8 - s
->rx_len
;
1073 static void strongarm_uart_receive(void *opaque
, const uint8_t *buf
, int size
)
1075 StrongARMUARTState
*s
= opaque
;
1078 for (i
= 0; i
< size
; i
++) {
1079 strongarm_uart_rx_push(s
, buf
[i
]);
1082 /* call the timeout receive callback in 3 char transmit time */
1083 timer_mod(s
->rx_timeout_timer
,
1084 qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL
) + s
->char_transmit_time
* 3);
1086 strongarm_uart_update_status(s
);
1087 strongarm_uart_update_int_status(s
);
1090 static void strongarm_uart_event(void *opaque
, int event
)
1092 StrongARMUARTState
*s
= opaque
;
1093 if (event
== CHR_EVENT_BREAK
) {
1094 s
->utsr0
|= UTSR0_RBB
;
1095 strongarm_uart_rx_push(s
, RX_FIFO_FRE
);
1096 s
->wait_break_end
= true;
1097 strongarm_uart_update_status(s
);
1098 strongarm_uart_update_int_status(s
);
1102 static void strongarm_uart_tx(void *opaque
)
1104 StrongARMUARTState
*s
= opaque
;
1105 uint64_t new_xmit_ts
= qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL
);
1107 if (s
->utcr3
& UTCR3_LBM
) /* loopback */ {
1108 strongarm_uart_receive(s
, &s
->tx_fifo
[s
->tx_start
], 1);
1109 } else if (qemu_chr_fe_get_driver(&s
->chr
)) {
1110 /* XXX this blocks entire thread. Rewrite to use
1111 * qemu_chr_fe_write and background I/O callbacks */
1112 qemu_chr_fe_write_all(&s
->chr
, &s
->tx_fifo
[s
->tx_start
], 1);
1115 s
->tx_start
= (s
->tx_start
+ 1) % 8;
1118 timer_mod(s
->tx_timer
, new_xmit_ts
+ s
->char_transmit_time
);
1120 strongarm_uart_update_status(s
);
1121 strongarm_uart_update_int_status(s
);
1124 static uint64_t strongarm_uart_read(void *opaque
, hwaddr addr
,
1127 StrongARMUARTState
*s
= opaque
;
1138 return s
->brd
& 0xff;
1144 if (s
->rx_len
!= 0) {
1145 ret
= s
->rx_fifo
[s
->rx_start
];
1146 s
->rx_start
= (s
->rx_start
+ 1) % 12;
1148 strongarm_uart_update_status(s
);
1149 strongarm_uart_update_int_status(s
);
1161 printf("%s: Bad register 0x" TARGET_FMT_plx
"\n", __func__
, addr
);
1166 static void strongarm_uart_write(void *opaque
, hwaddr addr
,
1167 uint64_t value
, unsigned size
)
1169 StrongARMUARTState
*s
= opaque
;
1173 s
->utcr0
= value
& 0x7f;
1174 strongarm_uart_update_parameters(s
);
1178 s
->brd
= (s
->brd
& 0xff) | ((value
& 0xf) << 8);
1179 strongarm_uart_update_parameters(s
);
1183 s
->brd
= (s
->brd
& 0xf00) | (value
& 0xff);
1184 strongarm_uart_update_parameters(s
);
1188 s
->utcr3
= value
& 0x3f;
1189 if ((s
->utcr3
& UTCR3_RXE
) == 0) {
1192 if ((s
->utcr3
& UTCR3_TXE
) == 0) {
1195 strongarm_uart_update_status(s
);
1196 strongarm_uart_update_int_status(s
);
1200 if ((s
->utcr3
& UTCR3_TXE
) && s
->tx_len
!= 8) {
1201 s
->tx_fifo
[(s
->tx_start
+ s
->tx_len
) % 8] = value
;
1203 strongarm_uart_update_status(s
);
1204 strongarm_uart_update_int_status(s
);
1205 if (s
->tx_len
== 1) {
1206 strongarm_uart_tx(s
);
1212 s
->utsr0
= s
->utsr0
& ~(value
&
1213 (UTSR0_REB
| UTSR0_RBB
| UTSR0_RID
));
1214 strongarm_uart_update_int_status(s
);
1218 printf("%s: Bad register 0x" TARGET_FMT_plx
"\n", __func__
, addr
);
1222 static const MemoryRegionOps strongarm_uart_ops
= {
1223 .read
= strongarm_uart_read
,
1224 .write
= strongarm_uart_write
,
1225 .endianness
= DEVICE_NATIVE_ENDIAN
,
1228 static void strongarm_uart_init(Object
*obj
)
1230 StrongARMUARTState
*s
= STRONGARM_UART(obj
);
1231 SysBusDevice
*dev
= SYS_BUS_DEVICE(obj
);
1233 memory_region_init_io(&s
->iomem
, obj
, &strongarm_uart_ops
, s
,
1235 sysbus_init_mmio(dev
, &s
->iomem
);
1236 sysbus_init_irq(dev
, &s
->irq
);
1238 s
->rx_timeout_timer
= timer_new_ns(QEMU_CLOCK_VIRTUAL
, strongarm_uart_rx_to
, s
);
1239 s
->tx_timer
= timer_new_ns(QEMU_CLOCK_VIRTUAL
, strongarm_uart_tx
, s
);
1242 static void strongarm_uart_realize(DeviceState
*dev
, Error
**errp
)
1244 StrongARMUARTState
*s
= STRONGARM_UART(dev
);
1246 qemu_chr_fe_set_handlers(&s
->chr
,
1247 strongarm_uart_can_receive
,
1248 strongarm_uart_receive
,
1249 strongarm_uart_event
,
1253 static void strongarm_uart_reset(DeviceState
*dev
)
1255 StrongARMUARTState
*s
= STRONGARM_UART(dev
);
1257 s
->utcr0
= UTCR0_DSS
; /* 8 data, no parity */
1258 s
->brd
= 23; /* 9600 */
1259 /* enable send & recv - this actually violates spec */
1260 s
->utcr3
= UTCR3_TXE
| UTCR3_RXE
;
1262 s
->rx_len
= s
->tx_len
= 0;
1264 strongarm_uart_update_parameters(s
);
1265 strongarm_uart_update_status(s
);
1266 strongarm_uart_update_int_status(s
);
1269 static int strongarm_uart_post_load(void *opaque
, int version_id
)
1271 StrongARMUARTState
*s
= opaque
;
1273 strongarm_uart_update_parameters(s
);
1274 strongarm_uart_update_status(s
);
1275 strongarm_uart_update_int_status(s
);
1277 /* tx and restart timer */
1279 strongarm_uart_tx(s
);
1282 /* restart rx timeout timer */
1284 timer_mod(s
->rx_timeout_timer
,
1285 qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL
) + s
->char_transmit_time
* 3);
1291 static const VMStateDescription vmstate_strongarm_uart_regs
= {
1292 .name
= "strongarm-uart",
1294 .minimum_version_id
= 0,
1295 .post_load
= strongarm_uart_post_load
,
1296 .fields
= (VMStateField
[]) {
1297 VMSTATE_UINT8(utcr0
, StrongARMUARTState
),
1298 VMSTATE_UINT16(brd
, StrongARMUARTState
),
1299 VMSTATE_UINT8(utcr3
, StrongARMUARTState
),
1300 VMSTATE_UINT8(utsr0
, StrongARMUARTState
),
1301 VMSTATE_UINT8_ARRAY(tx_fifo
, StrongARMUARTState
, 8),
1302 VMSTATE_UINT8(tx_start
, StrongARMUARTState
),
1303 VMSTATE_UINT8(tx_len
, StrongARMUARTState
),
1304 VMSTATE_UINT16_ARRAY(rx_fifo
, StrongARMUARTState
, 12),
1305 VMSTATE_UINT8(rx_start
, StrongARMUARTState
),
1306 VMSTATE_UINT8(rx_len
, StrongARMUARTState
),
1307 VMSTATE_BOOL(wait_break_end
, StrongARMUARTState
),
1308 VMSTATE_END_OF_LIST(),
1312 static Property strongarm_uart_properties
[] = {
1313 DEFINE_PROP_CHR("chardev", StrongARMUARTState
, chr
),
1314 DEFINE_PROP_END_OF_LIST(),
1317 static void strongarm_uart_class_init(ObjectClass
*klass
, void *data
)
1319 DeviceClass
*dc
= DEVICE_CLASS(klass
);
1321 dc
->desc
= "StrongARM UART controller";
1322 dc
->reset
= strongarm_uart_reset
;
1323 dc
->vmsd
= &vmstate_strongarm_uart_regs
;
1324 dc
->props
= strongarm_uart_properties
;
1325 dc
->realize
= strongarm_uart_realize
;
1328 static const TypeInfo strongarm_uart_info
= {
1329 .name
= TYPE_STRONGARM_UART
,
1330 .parent
= TYPE_SYS_BUS_DEVICE
,
1331 .instance_size
= sizeof(StrongARMUARTState
),
1332 .instance_init
= strongarm_uart_init
,
1333 .class_init
= strongarm_uart_class_init
,
1336 /* Synchronous Serial Ports */
1338 #define TYPE_STRONGARM_SSP "strongarm-ssp"
1339 #define STRONGARM_SSP(obj) \
1340 OBJECT_CHECK(StrongARMSSPState, (obj), TYPE_STRONGARM_SSP)
1342 typedef struct StrongARMSSPState
{
1343 SysBusDevice parent_obj
;
1352 uint16_t rx_fifo
[8];
1355 } StrongARMSSPState
;
1357 #define SSCR0 0x60 /* SSP Control register 0 */
1358 #define SSCR1 0x64 /* SSP Control register 1 */
1359 #define SSDR 0x6c /* SSP Data register */
1360 #define SSSR 0x74 /* SSP Status register */
1362 /* Bitfields for above registers */
1363 #define SSCR0_SPI(x) (((x) & 0x30) == 0x00)
1364 #define SSCR0_SSP(x) (((x) & 0x30) == 0x10)
1365 #define SSCR0_UWIRE(x) (((x) & 0x30) == 0x20)
1366 #define SSCR0_PSP(x) (((x) & 0x30) == 0x30)
1367 #define SSCR0_SSE (1 << 7)
1368 #define SSCR0_DSS(x) (((x) & 0xf) + 1)
1369 #define SSCR1_RIE (1 << 0)
1370 #define SSCR1_TIE (1 << 1)
1371 #define SSCR1_LBM (1 << 2)
1372 #define SSSR_TNF (1 << 2)
1373 #define SSSR_RNE (1 << 3)
1374 #define SSSR_TFS (1 << 5)
1375 #define SSSR_RFS (1 << 6)
1376 #define SSSR_ROR (1 << 7)
1377 #define SSSR_RW 0x0080
1379 static void strongarm_ssp_int_update(StrongARMSSPState
*s
)
1383 level
|= (s
->sssr
& SSSR_ROR
);
1384 level
|= (s
->sssr
& SSSR_RFS
) && (s
->sscr
[1] & SSCR1_RIE
);
1385 level
|= (s
->sssr
& SSSR_TFS
) && (s
->sscr
[1] & SSCR1_TIE
);
1386 qemu_set_irq(s
->irq
, level
);
1389 static void strongarm_ssp_fifo_update(StrongARMSSPState
*s
)
1391 s
->sssr
&= ~SSSR_TFS
;
1392 s
->sssr
&= ~SSSR_TNF
;
1393 if (s
->sscr
[0] & SSCR0_SSE
) {
1394 if (s
->rx_level
>= 4) {
1395 s
->sssr
|= SSSR_RFS
;
1397 s
->sssr
&= ~SSSR_RFS
;
1400 s
->sssr
|= SSSR_RNE
;
1402 s
->sssr
&= ~SSSR_RNE
;
1404 /* TX FIFO is never filled, so it is always in underrun
1405 condition if SSP is enabled */
1406 s
->sssr
|= SSSR_TFS
;
1407 s
->sssr
|= SSSR_TNF
;
1410 strongarm_ssp_int_update(s
);
1413 static uint64_t strongarm_ssp_read(void *opaque
, hwaddr addr
,
1416 StrongARMSSPState
*s
= opaque
;
1427 if (~s
->sscr
[0] & SSCR0_SSE
) {
1430 if (s
->rx_level
< 1) {
1431 printf("%s: SSP Rx Underrun\n", __func__
);
1435 retval
= s
->rx_fifo
[s
->rx_start
++];
1437 strongarm_ssp_fifo_update(s
);
1440 printf("%s: Bad register 0x" TARGET_FMT_plx
"\n", __func__
, addr
);
1446 static void strongarm_ssp_write(void *opaque
, hwaddr addr
,
1447 uint64_t value
, unsigned size
)
1449 StrongARMSSPState
*s
= opaque
;
1453 s
->sscr
[0] = value
& 0xffbf;
1454 if ((s
->sscr
[0] & SSCR0_SSE
) && SSCR0_DSS(value
) < 4) {
1455 printf("%s: Wrong data size: %i bits\n", __func__
,
1456 (int)SSCR0_DSS(value
));
1458 if (!(value
& SSCR0_SSE
)) {
1462 strongarm_ssp_fifo_update(s
);
1466 s
->sscr
[1] = value
& 0x2f;
1467 if (value
& SSCR1_LBM
) {
1468 printf("%s: Attempt to use SSP LBM mode\n", __func__
);
1470 strongarm_ssp_fifo_update(s
);
1474 s
->sssr
&= ~(value
& SSSR_RW
);
1475 strongarm_ssp_int_update(s
);
1479 if (SSCR0_UWIRE(s
->sscr
[0])) {
1482 /* Note how 32bits overflow does no harm here */
1483 value
&= (1 << SSCR0_DSS(s
->sscr
[0])) - 1;
1485 /* Data goes from here to the Tx FIFO and is shifted out from
1486 * there directly to the slave, no need to buffer it.
1488 if (s
->sscr
[0] & SSCR0_SSE
) {
1490 if (s
->sscr
[1] & SSCR1_LBM
) {
1493 readval
= ssi_transfer(s
->bus
, value
);
1496 if (s
->rx_level
< 0x08) {
1497 s
->rx_fifo
[(s
->rx_start
+ s
->rx_level
++) & 0x7] = readval
;
1499 s
->sssr
|= SSSR_ROR
;
1502 strongarm_ssp_fifo_update(s
);
1506 printf("%s: Bad register 0x" TARGET_FMT_plx
"\n", __func__
, addr
);
1511 static const MemoryRegionOps strongarm_ssp_ops
= {
1512 .read
= strongarm_ssp_read
,
1513 .write
= strongarm_ssp_write
,
1514 .endianness
= DEVICE_NATIVE_ENDIAN
,
1517 static int strongarm_ssp_post_load(void *opaque
, int version_id
)
1519 StrongARMSSPState
*s
= opaque
;
1521 strongarm_ssp_fifo_update(s
);
1526 static void strongarm_ssp_init(Object
*obj
)
1528 SysBusDevice
*sbd
= SYS_BUS_DEVICE(obj
);
1529 DeviceState
*dev
= DEVICE(sbd
);
1530 StrongARMSSPState
*s
= STRONGARM_SSP(dev
);
1532 sysbus_init_irq(sbd
, &s
->irq
);
1534 memory_region_init_io(&s
->iomem
, obj
, &strongarm_ssp_ops
, s
,
1536 sysbus_init_mmio(sbd
, &s
->iomem
);
1538 s
->bus
= ssi_create_bus(dev
, "ssi");
1541 static void strongarm_ssp_reset(DeviceState
*dev
)
1543 StrongARMSSPState
*s
= STRONGARM_SSP(dev
);
1545 s
->sssr
= 0x03; /* 3 bit data, SPI, disabled */
1550 static const VMStateDescription vmstate_strongarm_ssp_regs
= {
1551 .name
= "strongarm-ssp",
1553 .minimum_version_id
= 0,
1554 .post_load
= strongarm_ssp_post_load
,
1555 .fields
= (VMStateField
[]) {
1556 VMSTATE_UINT16_ARRAY(sscr
, StrongARMSSPState
, 2),
1557 VMSTATE_UINT16(sssr
, StrongARMSSPState
),
1558 VMSTATE_UINT16_ARRAY(rx_fifo
, StrongARMSSPState
, 8),
1559 VMSTATE_UINT8(rx_start
, StrongARMSSPState
),
1560 VMSTATE_UINT8(rx_level
, StrongARMSSPState
),
1561 VMSTATE_END_OF_LIST(),
1565 static void strongarm_ssp_class_init(ObjectClass
*klass
, void *data
)
1567 DeviceClass
*dc
= DEVICE_CLASS(klass
);
1569 dc
->desc
= "StrongARM SSP controller";
1570 dc
->reset
= strongarm_ssp_reset
;
1571 dc
->vmsd
= &vmstate_strongarm_ssp_regs
;
1574 static const TypeInfo strongarm_ssp_info
= {
1575 .name
= TYPE_STRONGARM_SSP
,
1576 .parent
= TYPE_SYS_BUS_DEVICE
,
1577 .instance_size
= sizeof(StrongARMSSPState
),
1578 .instance_init
= strongarm_ssp_init
,
1579 .class_init
= strongarm_ssp_class_init
,
1582 /* Main CPU functions */
1583 StrongARMState
*sa1110_init(MemoryRegion
*sysmem
,
1584 unsigned int sdram_size
, const char *rev
)
1589 s
= g_new0(StrongARMState
, 1);
1595 if (strncmp(rev
, "sa1110", 6)) {
1596 error_report("Machine requires a SA1110 processor.");
1600 s
->cpu
= cpu_arm_init(rev
);
1603 error_report("Unable to find CPU definition");
1607 memory_region_allocate_system_memory(&s
->sdram
, NULL
, "strongarm.sdram",
1609 memory_region_add_subregion(sysmem
, SA_SDCS0
, &s
->sdram
);
1611 s
->pic
= sysbus_create_varargs("strongarm_pic", 0x90050000,
1612 qdev_get_gpio_in(DEVICE(s
->cpu
), ARM_CPU_IRQ
),
1613 qdev_get_gpio_in(DEVICE(s
->cpu
), ARM_CPU_FIQ
),
1616 sysbus_create_varargs("pxa25x-timer", 0x90000000,
1617 qdev_get_gpio_in(s
->pic
, SA_PIC_OSTC0
),
1618 qdev_get_gpio_in(s
->pic
, SA_PIC_OSTC1
),
1619 qdev_get_gpio_in(s
->pic
, SA_PIC_OSTC2
),
1620 qdev_get_gpio_in(s
->pic
, SA_PIC_OSTC3
),
1623 sysbus_create_simple(TYPE_STRONGARM_RTC
, 0x90010000,
1624 qdev_get_gpio_in(s
->pic
, SA_PIC_RTC_ALARM
));
1626 s
->gpio
= strongarm_gpio_init(0x90040000, s
->pic
);
1628 s
->ppc
= sysbus_create_varargs(TYPE_STRONGARM_PPC
, 0x90060000, NULL
);
1630 for (i
= 0; sa_serial
[i
].io_base
; i
++) {
1631 DeviceState
*dev
= qdev_create(NULL
, TYPE_STRONGARM_UART
);
1632 qdev_prop_set_chr(dev
, "chardev", serial_hds
[i
]);
1633 qdev_init_nofail(dev
);
1634 sysbus_mmio_map(SYS_BUS_DEVICE(dev
), 0,
1635 sa_serial
[i
].io_base
);
1636 sysbus_connect_irq(SYS_BUS_DEVICE(dev
), 0,
1637 qdev_get_gpio_in(s
->pic
, sa_serial
[i
].irq
));
1640 s
->ssp
= sysbus_create_varargs(TYPE_STRONGARM_SSP
, 0x80070000,
1641 qdev_get_gpio_in(s
->pic
, SA_PIC_SSP
), NULL
);
1642 s
->ssp_bus
= (SSIBus
*)qdev_get_child_bus(s
->ssp
, "ssi");
1647 static void strongarm_register_types(void)
1649 type_register_static(&strongarm_pic_info
);
1650 type_register_static(&strongarm_rtc_sysbus_info
);
1651 type_register_static(&strongarm_gpio_info
);
1652 type_register_static(&strongarm_ppc_info
);
1653 type_register_static(&strongarm_uart_info
);
1654 type_register_static(&strongarm_ssp_info
);
1657 type_init(strongarm_register_types
)