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 int strongarm_rtc_pre_save(void *opaque
)
411 StrongARMRTCState
*s
= opaque
;
413 strongarm_rtc_hzupdate(s
);
418 static int strongarm_rtc_post_load(void *opaque
, int version_id
)
420 StrongARMRTCState
*s
= opaque
;
422 strongarm_rtc_timer_update(s
);
423 strongarm_rtc_int_update(s
);
428 static const VMStateDescription vmstate_strongarm_rtc_regs
= {
429 .name
= "strongarm-rtc",
431 .minimum_version_id
= 0,
432 .pre_save
= strongarm_rtc_pre_save
,
433 .post_load
= strongarm_rtc_post_load
,
434 .fields
= (VMStateField
[]) {
435 VMSTATE_UINT32(rttr
, StrongARMRTCState
),
436 VMSTATE_UINT32(rtsr
, StrongARMRTCState
),
437 VMSTATE_UINT32(rtar
, StrongARMRTCState
),
438 VMSTATE_UINT32(last_rcnr
, StrongARMRTCState
),
439 VMSTATE_INT64(last_hz
, StrongARMRTCState
),
440 VMSTATE_END_OF_LIST(),
444 static void strongarm_rtc_sysbus_class_init(ObjectClass
*klass
, void *data
)
446 DeviceClass
*dc
= DEVICE_CLASS(klass
);
448 dc
->desc
= "StrongARM RTC Controller";
449 dc
->vmsd
= &vmstate_strongarm_rtc_regs
;
452 static const TypeInfo strongarm_rtc_sysbus_info
= {
453 .name
= TYPE_STRONGARM_RTC
,
454 .parent
= TYPE_SYS_BUS_DEVICE
,
455 .instance_size
= sizeof(StrongARMRTCState
),
456 .instance_init
= strongarm_rtc_init
,
457 .class_init
= strongarm_rtc_sysbus_class_init
,
470 #define TYPE_STRONGARM_GPIO "strongarm-gpio"
471 #define STRONGARM_GPIO(obj) \
472 OBJECT_CHECK(StrongARMGPIOInfo, (obj), TYPE_STRONGARM_GPIO)
474 typedef struct StrongARMGPIOInfo StrongARMGPIOInfo
;
475 struct StrongARMGPIOInfo
{
478 qemu_irq handler
[28];
494 static void strongarm_gpio_irq_update(StrongARMGPIOInfo
*s
)
497 for (i
= 0; i
< 11; i
++) {
498 qemu_set_irq(s
->irqs
[i
], s
->status
& (1 << i
));
501 qemu_set_irq(s
->irqX
, (s
->status
& ~0x7ff));
504 static void strongarm_gpio_set(void *opaque
, int line
, int level
)
506 StrongARMGPIOInfo
*s
= opaque
;
512 s
->status
|= s
->rising
& mask
&
513 ~s
->ilevel
& ~s
->dir
;
516 s
->status
|= s
->falling
& mask
&
521 if (s
->status
& mask
) {
522 strongarm_gpio_irq_update(s
);
526 static void strongarm_gpio_handler_update(StrongARMGPIOInfo
*s
)
528 uint32_t level
, diff
;
531 level
= s
->olevel
& s
->dir
;
533 for (diff
= s
->prev_level
^ level
; diff
; diff
^= 1 << bit
) {
535 qemu_set_irq(s
->handler
[bit
], (level
>> bit
) & 1);
538 s
->prev_level
= level
;
541 static uint64_t strongarm_gpio_read(void *opaque
, hwaddr offset
,
544 StrongARMGPIOInfo
*s
= opaque
;
547 case GPDR
: /* GPIO Pin-Direction registers */
550 case GPSR
: /* GPIO Pin-Output Set registers */
551 qemu_log_mask(LOG_GUEST_ERROR
,
552 "strongarm GPIO: read from write only register GPSR\n");
555 case GPCR
: /* GPIO Pin-Output Clear registers */
556 qemu_log_mask(LOG_GUEST_ERROR
,
557 "strongarm GPIO: read from write only register GPCR\n");
560 case GRER
: /* GPIO Rising-Edge Detect Enable registers */
563 case GFER
: /* GPIO Falling-Edge Detect Enable registers */
566 case GAFR
: /* GPIO Alternate Function registers */
569 case GPLR
: /* GPIO Pin-Level registers */
570 return (s
->olevel
& s
->dir
) |
571 (s
->ilevel
& ~s
->dir
);
573 case GEDR
: /* GPIO Edge Detect Status registers */
577 printf("%s: Bad offset 0x" TARGET_FMT_plx
"\n", __func__
, offset
);
583 static void strongarm_gpio_write(void *opaque
, hwaddr offset
,
584 uint64_t value
, unsigned size
)
586 StrongARMGPIOInfo
*s
= opaque
;
589 case GPDR
: /* GPIO Pin-Direction registers */
591 strongarm_gpio_handler_update(s
);
594 case GPSR
: /* GPIO Pin-Output Set registers */
596 strongarm_gpio_handler_update(s
);
599 case GPCR
: /* GPIO Pin-Output Clear registers */
601 strongarm_gpio_handler_update(s
);
604 case GRER
: /* GPIO Rising-Edge Detect Enable registers */
608 case GFER
: /* GPIO Falling-Edge Detect Enable registers */
612 case GAFR
: /* GPIO Alternate Function registers */
616 case GEDR
: /* GPIO Edge Detect Status registers */
618 strongarm_gpio_irq_update(s
);
622 printf("%s: Bad offset 0x" TARGET_FMT_plx
"\n", __func__
, offset
);
626 static const MemoryRegionOps strongarm_gpio_ops
= {
627 .read
= strongarm_gpio_read
,
628 .write
= strongarm_gpio_write
,
629 .endianness
= DEVICE_NATIVE_ENDIAN
,
632 static DeviceState
*strongarm_gpio_init(hwaddr base
,
638 dev
= qdev_create(NULL
, TYPE_STRONGARM_GPIO
);
639 qdev_init_nofail(dev
);
641 sysbus_mmio_map(SYS_BUS_DEVICE(dev
), 0, base
);
642 for (i
= 0; i
< 12; i
++)
643 sysbus_connect_irq(SYS_BUS_DEVICE(dev
), i
,
644 qdev_get_gpio_in(pic
, SA_PIC_GPIO0_EDGE
+ i
));
649 static void strongarm_gpio_initfn(Object
*obj
)
651 DeviceState
*dev
= DEVICE(obj
);
652 StrongARMGPIOInfo
*s
= STRONGARM_GPIO(obj
);
653 SysBusDevice
*sbd
= SYS_BUS_DEVICE(obj
);
656 qdev_init_gpio_in(dev
, strongarm_gpio_set
, 28);
657 qdev_init_gpio_out(dev
, s
->handler
, 28);
659 memory_region_init_io(&s
->iomem
, obj
, &strongarm_gpio_ops
, s
,
662 sysbus_init_mmio(sbd
, &s
->iomem
);
663 for (i
= 0; i
< 11; i
++) {
664 sysbus_init_irq(sbd
, &s
->irqs
[i
]);
666 sysbus_init_irq(sbd
, &s
->irqX
);
669 static const VMStateDescription vmstate_strongarm_gpio_regs
= {
670 .name
= "strongarm-gpio",
672 .minimum_version_id
= 0,
673 .fields
= (VMStateField
[]) {
674 VMSTATE_UINT32(ilevel
, StrongARMGPIOInfo
),
675 VMSTATE_UINT32(olevel
, StrongARMGPIOInfo
),
676 VMSTATE_UINT32(dir
, StrongARMGPIOInfo
),
677 VMSTATE_UINT32(rising
, StrongARMGPIOInfo
),
678 VMSTATE_UINT32(falling
, StrongARMGPIOInfo
),
679 VMSTATE_UINT32(status
, StrongARMGPIOInfo
),
680 VMSTATE_UINT32(gafr
, StrongARMGPIOInfo
),
681 VMSTATE_UINT32(prev_level
, StrongARMGPIOInfo
),
682 VMSTATE_END_OF_LIST(),
686 static void strongarm_gpio_class_init(ObjectClass
*klass
, void *data
)
688 DeviceClass
*dc
= DEVICE_CLASS(klass
);
690 dc
->desc
= "StrongARM GPIO controller";
691 dc
->vmsd
= &vmstate_strongarm_gpio_regs
;
694 static const TypeInfo strongarm_gpio_info
= {
695 .name
= TYPE_STRONGARM_GPIO
,
696 .parent
= TYPE_SYS_BUS_DEVICE
,
697 .instance_size
= sizeof(StrongARMGPIOInfo
),
698 .instance_init
= strongarm_gpio_initfn
,
699 .class_init
= strongarm_gpio_class_init
,
702 /* Peripheral Pin Controller */
709 #define TYPE_STRONGARM_PPC "strongarm-ppc"
710 #define STRONGARM_PPC(obj) \
711 OBJECT_CHECK(StrongARMPPCInfo, (obj), TYPE_STRONGARM_PPC)
713 typedef struct StrongARMPPCInfo StrongARMPPCInfo
;
714 struct StrongARMPPCInfo
{
715 SysBusDevice parent_obj
;
718 qemu_irq handler
[28];
730 static void strongarm_ppc_set(void *opaque
, int line
, int level
)
732 StrongARMPPCInfo
*s
= opaque
;
735 s
->ilevel
|= 1 << line
;
737 s
->ilevel
&= ~(1 << line
);
741 static void strongarm_ppc_handler_update(StrongARMPPCInfo
*s
)
743 uint32_t level
, diff
;
746 level
= s
->olevel
& s
->dir
;
748 for (diff
= s
->prev_level
^ level
; diff
; diff
^= 1 << bit
) {
750 qemu_set_irq(s
->handler
[bit
], (level
>> bit
) & 1);
753 s
->prev_level
= level
;
756 static uint64_t strongarm_ppc_read(void *opaque
, hwaddr offset
,
759 StrongARMPPCInfo
*s
= opaque
;
762 case PPDR
: /* PPC Pin Direction registers */
763 return s
->dir
| ~0x3fffff;
765 case PPSR
: /* PPC Pin State registers */
766 return (s
->olevel
& s
->dir
) |
767 (s
->ilevel
& ~s
->dir
) |
771 return s
->ppar
| ~0x41000;
777 return s
->ppfr
| ~0x7f001;
780 printf("%s: Bad offset 0x" TARGET_FMT_plx
"\n", __func__
, offset
);
786 static void strongarm_ppc_write(void *opaque
, hwaddr offset
,
787 uint64_t value
, unsigned size
)
789 StrongARMPPCInfo
*s
= opaque
;
792 case PPDR
: /* PPC Pin Direction registers */
793 s
->dir
= value
& 0x3fffff;
794 strongarm_ppc_handler_update(s
);
797 case PPSR
: /* PPC Pin State registers */
798 s
->olevel
= value
& s
->dir
& 0x3fffff;
799 strongarm_ppc_handler_update(s
);
803 s
->ppar
= value
& 0x41000;
807 s
->psdr
= value
& 0x3fffff;
811 s
->ppfr
= value
& 0x7f001;
815 printf("%s: Bad offset 0x" TARGET_FMT_plx
"\n", __func__
, offset
);
819 static const MemoryRegionOps strongarm_ppc_ops
= {
820 .read
= strongarm_ppc_read
,
821 .write
= strongarm_ppc_write
,
822 .endianness
= DEVICE_NATIVE_ENDIAN
,
825 static void strongarm_ppc_init(Object
*obj
)
827 DeviceState
*dev
= DEVICE(obj
);
828 StrongARMPPCInfo
*s
= STRONGARM_PPC(obj
);
829 SysBusDevice
*sbd
= SYS_BUS_DEVICE(obj
);
831 qdev_init_gpio_in(dev
, strongarm_ppc_set
, 22);
832 qdev_init_gpio_out(dev
, s
->handler
, 22);
834 memory_region_init_io(&s
->iomem
, obj
, &strongarm_ppc_ops
, s
,
837 sysbus_init_mmio(sbd
, &s
->iomem
);
840 static const VMStateDescription vmstate_strongarm_ppc_regs
= {
841 .name
= "strongarm-ppc",
843 .minimum_version_id
= 0,
844 .fields
= (VMStateField
[]) {
845 VMSTATE_UINT32(ilevel
, StrongARMPPCInfo
),
846 VMSTATE_UINT32(olevel
, StrongARMPPCInfo
),
847 VMSTATE_UINT32(dir
, StrongARMPPCInfo
),
848 VMSTATE_UINT32(ppar
, StrongARMPPCInfo
),
849 VMSTATE_UINT32(psdr
, StrongARMPPCInfo
),
850 VMSTATE_UINT32(ppfr
, StrongARMPPCInfo
),
851 VMSTATE_UINT32(prev_level
, StrongARMPPCInfo
),
852 VMSTATE_END_OF_LIST(),
856 static void strongarm_ppc_class_init(ObjectClass
*klass
, void *data
)
858 DeviceClass
*dc
= DEVICE_CLASS(klass
);
860 dc
->desc
= "StrongARM PPC controller";
861 dc
->vmsd
= &vmstate_strongarm_ppc_regs
;
864 static const TypeInfo strongarm_ppc_info
= {
865 .name
= TYPE_STRONGARM_PPC
,
866 .parent
= TYPE_SYS_BUS_DEVICE
,
867 .instance_size
= sizeof(StrongARMPPCInfo
),
868 .instance_init
= strongarm_ppc_init
,
869 .class_init
= strongarm_ppc_class_init
,
881 #define UTCR0_PE (1 << 0) /* Parity enable */
882 #define UTCR0_OES (1 << 1) /* Even parity */
883 #define UTCR0_SBS (1 << 2) /* 2 stop bits */
884 #define UTCR0_DSS (1 << 3) /* 8-bit data */
886 #define UTCR3_RXE (1 << 0) /* Rx enable */
887 #define UTCR3_TXE (1 << 1) /* Tx enable */
888 #define UTCR3_BRK (1 << 2) /* Force Break */
889 #define UTCR3_RIE (1 << 3) /* Rx int enable */
890 #define UTCR3_TIE (1 << 4) /* Tx int enable */
891 #define UTCR3_LBM (1 << 5) /* Loopback */
893 #define UTSR0_TFS (1 << 0) /* Tx FIFO nearly empty */
894 #define UTSR0_RFS (1 << 1) /* Rx FIFO nearly full */
895 #define UTSR0_RID (1 << 2) /* Receiver Idle */
896 #define UTSR0_RBB (1 << 3) /* Receiver begin break */
897 #define UTSR0_REB (1 << 4) /* Receiver end break */
898 #define UTSR0_EIF (1 << 5) /* Error in FIFO */
900 #define UTSR1_RNE (1 << 1) /* Receive FIFO not empty */
901 #define UTSR1_TNF (1 << 2) /* Transmit FIFO not full */
902 #define UTSR1_PRE (1 << 3) /* Parity error */
903 #define UTSR1_FRE (1 << 4) /* Frame error */
904 #define UTSR1_ROR (1 << 5) /* Receive Over Run */
906 #define RX_FIFO_PRE (1 << 8)
907 #define RX_FIFO_FRE (1 << 9)
908 #define RX_FIFO_ROR (1 << 10)
910 #define TYPE_STRONGARM_UART "strongarm-uart"
911 #define STRONGARM_UART(obj) \
912 OBJECT_CHECK(StrongARMUARTState, (obj), TYPE_STRONGARM_UART)
914 typedef struct StrongARMUARTState
{
915 SysBusDevice parent_obj
;
930 uint16_t rx_fifo
[12]; /* value + error flags in high bits */
934 uint64_t char_transmit_time
; /* time to transmit a char in ticks*/
936 QEMUTimer
*rx_timeout_timer
;
938 } StrongARMUARTState
;
940 static void strongarm_uart_update_status(StrongARMUARTState
*s
)
944 if (s
->tx_len
!= 8) {
948 if (s
->rx_len
!= 0) {
949 uint16_t ent
= s
->rx_fifo
[s
->rx_start
];
952 if (ent
& RX_FIFO_PRE
) {
953 s
->utsr1
|= UTSR1_PRE
;
955 if (ent
& RX_FIFO_FRE
) {
956 s
->utsr1
|= UTSR1_FRE
;
958 if (ent
& RX_FIFO_ROR
) {
959 s
->utsr1
|= UTSR1_ROR
;
966 static void strongarm_uart_update_int_status(StrongARMUARTState
*s
)
968 uint16_t utsr0
= s
->utsr0
&
969 (UTSR0_REB
| UTSR0_RBB
| UTSR0_RID
);
972 if ((s
->utcr3
& UTCR3_TXE
) &&
973 (s
->utcr3
& UTCR3_TIE
) &&
978 if ((s
->utcr3
& UTCR3_RXE
) &&
979 (s
->utcr3
& UTCR3_RIE
) &&
984 for (i
= 0; i
< s
->rx_len
&& i
< 4; i
++)
985 if (s
->rx_fifo
[(s
->rx_start
+ i
) % 12] & ~0xff) {
991 qemu_set_irq(s
->irq
, utsr0
);
994 static void strongarm_uart_update_parameters(StrongARMUARTState
*s
)
996 int speed
, parity
, data_bits
, stop_bits
, frame_size
;
997 QEMUSerialSetParams ssp
;
1001 if (s
->utcr0
& UTCR0_PE
) {
1004 if (s
->utcr0
& UTCR0_OES
) {
1012 if (s
->utcr0
& UTCR0_SBS
) {
1018 data_bits
= (s
->utcr0
& UTCR0_DSS
) ? 8 : 7;
1019 frame_size
+= data_bits
+ stop_bits
;
1020 speed
= 3686400 / 16 / (s
->brd
+ 1);
1022 ssp
.parity
= parity
;
1023 ssp
.data_bits
= data_bits
;
1024 ssp
.stop_bits
= stop_bits
;
1025 s
->char_transmit_time
= (NANOSECONDS_PER_SECOND
/ speed
) * frame_size
;
1026 qemu_chr_fe_ioctl(&s
->chr
, CHR_IOCTL_SERIAL_SET_PARAMS
, &ssp
);
1028 DPRINTF(stderr
, "%s speed=%d parity=%c data=%d stop=%d\n", s
->chr
->label
,
1029 speed
, parity
, data_bits
, stop_bits
);
1032 static void strongarm_uart_rx_to(void *opaque
)
1034 StrongARMUARTState
*s
= opaque
;
1037 s
->utsr0
|= UTSR0_RID
;
1038 strongarm_uart_update_int_status(s
);
1042 static void strongarm_uart_rx_push(StrongARMUARTState
*s
, uint16_t c
)
1044 if ((s
->utcr3
& UTCR3_RXE
) == 0) {
1049 if (s
->wait_break_end
) {
1050 s
->utsr0
|= UTSR0_REB
;
1051 s
->wait_break_end
= false;
1054 if (s
->rx_len
< 12) {
1055 s
->rx_fifo
[(s
->rx_start
+ s
->rx_len
) % 12] = c
;
1058 s
->rx_fifo
[(s
->rx_start
+ 11) % 12] |= RX_FIFO_ROR
;
1061 static int strongarm_uart_can_receive(void *opaque
)
1063 StrongARMUARTState
*s
= opaque
;
1065 if (s
->rx_len
== 12) {
1068 /* It's best not to get more than 2/3 of RX FIFO, so advertise that much */
1069 if (s
->rx_len
< 8) {
1070 return 8 - s
->rx_len
;
1075 static void strongarm_uart_receive(void *opaque
, const uint8_t *buf
, int size
)
1077 StrongARMUARTState
*s
= opaque
;
1080 for (i
= 0; i
< size
; i
++) {
1081 strongarm_uart_rx_push(s
, buf
[i
]);
1084 /* call the timeout receive callback in 3 char transmit time */
1085 timer_mod(s
->rx_timeout_timer
,
1086 qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL
) + s
->char_transmit_time
* 3);
1088 strongarm_uart_update_status(s
);
1089 strongarm_uart_update_int_status(s
);
1092 static void strongarm_uart_event(void *opaque
, int event
)
1094 StrongARMUARTState
*s
= opaque
;
1095 if (event
== CHR_EVENT_BREAK
) {
1096 s
->utsr0
|= UTSR0_RBB
;
1097 strongarm_uart_rx_push(s
, RX_FIFO_FRE
);
1098 s
->wait_break_end
= true;
1099 strongarm_uart_update_status(s
);
1100 strongarm_uart_update_int_status(s
);
1104 static void strongarm_uart_tx(void *opaque
)
1106 StrongARMUARTState
*s
= opaque
;
1107 uint64_t new_xmit_ts
= qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL
);
1109 if (s
->utcr3
& UTCR3_LBM
) /* loopback */ {
1110 strongarm_uart_receive(s
, &s
->tx_fifo
[s
->tx_start
], 1);
1111 } else if (qemu_chr_fe_backend_connected(&s
->chr
)) {
1112 /* XXX this blocks entire thread. Rewrite to use
1113 * qemu_chr_fe_write and background I/O callbacks */
1114 qemu_chr_fe_write_all(&s
->chr
, &s
->tx_fifo
[s
->tx_start
], 1);
1117 s
->tx_start
= (s
->tx_start
+ 1) % 8;
1120 timer_mod(s
->tx_timer
, new_xmit_ts
+ s
->char_transmit_time
);
1122 strongarm_uart_update_status(s
);
1123 strongarm_uart_update_int_status(s
);
1126 static uint64_t strongarm_uart_read(void *opaque
, hwaddr addr
,
1129 StrongARMUARTState
*s
= opaque
;
1140 return s
->brd
& 0xff;
1146 if (s
->rx_len
!= 0) {
1147 ret
= s
->rx_fifo
[s
->rx_start
];
1148 s
->rx_start
= (s
->rx_start
+ 1) % 12;
1150 strongarm_uart_update_status(s
);
1151 strongarm_uart_update_int_status(s
);
1163 printf("%s: Bad register 0x" TARGET_FMT_plx
"\n", __func__
, addr
);
1168 static void strongarm_uart_write(void *opaque
, hwaddr addr
,
1169 uint64_t value
, unsigned size
)
1171 StrongARMUARTState
*s
= opaque
;
1175 s
->utcr0
= value
& 0x7f;
1176 strongarm_uart_update_parameters(s
);
1180 s
->brd
= (s
->brd
& 0xff) | ((value
& 0xf) << 8);
1181 strongarm_uart_update_parameters(s
);
1185 s
->brd
= (s
->brd
& 0xf00) | (value
& 0xff);
1186 strongarm_uart_update_parameters(s
);
1190 s
->utcr3
= value
& 0x3f;
1191 if ((s
->utcr3
& UTCR3_RXE
) == 0) {
1194 if ((s
->utcr3
& UTCR3_TXE
) == 0) {
1197 strongarm_uart_update_status(s
);
1198 strongarm_uart_update_int_status(s
);
1202 if ((s
->utcr3
& UTCR3_TXE
) && s
->tx_len
!= 8) {
1203 s
->tx_fifo
[(s
->tx_start
+ s
->tx_len
) % 8] = value
;
1205 strongarm_uart_update_status(s
);
1206 strongarm_uart_update_int_status(s
);
1207 if (s
->tx_len
== 1) {
1208 strongarm_uart_tx(s
);
1214 s
->utsr0
= s
->utsr0
& ~(value
&
1215 (UTSR0_REB
| UTSR0_RBB
| UTSR0_RID
));
1216 strongarm_uart_update_int_status(s
);
1220 printf("%s: Bad register 0x" TARGET_FMT_plx
"\n", __func__
, addr
);
1224 static const MemoryRegionOps strongarm_uart_ops
= {
1225 .read
= strongarm_uart_read
,
1226 .write
= strongarm_uart_write
,
1227 .endianness
= DEVICE_NATIVE_ENDIAN
,
1230 static void strongarm_uart_init(Object
*obj
)
1232 StrongARMUARTState
*s
= STRONGARM_UART(obj
);
1233 SysBusDevice
*dev
= SYS_BUS_DEVICE(obj
);
1235 memory_region_init_io(&s
->iomem
, obj
, &strongarm_uart_ops
, s
,
1237 sysbus_init_mmio(dev
, &s
->iomem
);
1238 sysbus_init_irq(dev
, &s
->irq
);
1240 s
->rx_timeout_timer
= timer_new_ns(QEMU_CLOCK_VIRTUAL
, strongarm_uart_rx_to
, s
);
1241 s
->tx_timer
= timer_new_ns(QEMU_CLOCK_VIRTUAL
, strongarm_uart_tx
, s
);
1244 static void strongarm_uart_realize(DeviceState
*dev
, Error
**errp
)
1246 StrongARMUARTState
*s
= STRONGARM_UART(dev
);
1248 qemu_chr_fe_set_handlers(&s
->chr
,
1249 strongarm_uart_can_receive
,
1250 strongarm_uart_receive
,
1251 strongarm_uart_event
,
1252 NULL
, s
, NULL
, true);
1255 static void strongarm_uart_reset(DeviceState
*dev
)
1257 StrongARMUARTState
*s
= STRONGARM_UART(dev
);
1259 s
->utcr0
= UTCR0_DSS
; /* 8 data, no parity */
1260 s
->brd
= 23; /* 9600 */
1261 /* enable send & recv - this actually violates spec */
1262 s
->utcr3
= UTCR3_TXE
| UTCR3_RXE
;
1264 s
->rx_len
= s
->tx_len
= 0;
1266 strongarm_uart_update_parameters(s
);
1267 strongarm_uart_update_status(s
);
1268 strongarm_uart_update_int_status(s
);
1271 static int strongarm_uart_post_load(void *opaque
, int version_id
)
1273 StrongARMUARTState
*s
= opaque
;
1275 strongarm_uart_update_parameters(s
);
1276 strongarm_uart_update_status(s
);
1277 strongarm_uart_update_int_status(s
);
1279 /* tx and restart timer */
1281 strongarm_uart_tx(s
);
1284 /* restart rx timeout timer */
1286 timer_mod(s
->rx_timeout_timer
,
1287 qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL
) + s
->char_transmit_time
* 3);
1293 static const VMStateDescription vmstate_strongarm_uart_regs
= {
1294 .name
= "strongarm-uart",
1296 .minimum_version_id
= 0,
1297 .post_load
= strongarm_uart_post_load
,
1298 .fields
= (VMStateField
[]) {
1299 VMSTATE_UINT8(utcr0
, StrongARMUARTState
),
1300 VMSTATE_UINT16(brd
, StrongARMUARTState
),
1301 VMSTATE_UINT8(utcr3
, StrongARMUARTState
),
1302 VMSTATE_UINT8(utsr0
, StrongARMUARTState
),
1303 VMSTATE_UINT8_ARRAY(tx_fifo
, StrongARMUARTState
, 8),
1304 VMSTATE_UINT8(tx_start
, StrongARMUARTState
),
1305 VMSTATE_UINT8(tx_len
, StrongARMUARTState
),
1306 VMSTATE_UINT16_ARRAY(rx_fifo
, StrongARMUARTState
, 12),
1307 VMSTATE_UINT8(rx_start
, StrongARMUARTState
),
1308 VMSTATE_UINT8(rx_len
, StrongARMUARTState
),
1309 VMSTATE_BOOL(wait_break_end
, StrongARMUARTState
),
1310 VMSTATE_END_OF_LIST(),
1314 static Property strongarm_uart_properties
[] = {
1315 DEFINE_PROP_CHR("chardev", StrongARMUARTState
, chr
),
1316 DEFINE_PROP_END_OF_LIST(),
1319 static void strongarm_uart_class_init(ObjectClass
*klass
, void *data
)
1321 DeviceClass
*dc
= DEVICE_CLASS(klass
);
1323 dc
->desc
= "StrongARM UART controller";
1324 dc
->reset
= strongarm_uart_reset
;
1325 dc
->vmsd
= &vmstate_strongarm_uart_regs
;
1326 dc
->props
= strongarm_uart_properties
;
1327 dc
->realize
= strongarm_uart_realize
;
1330 static const TypeInfo strongarm_uart_info
= {
1331 .name
= TYPE_STRONGARM_UART
,
1332 .parent
= TYPE_SYS_BUS_DEVICE
,
1333 .instance_size
= sizeof(StrongARMUARTState
),
1334 .instance_init
= strongarm_uart_init
,
1335 .class_init
= strongarm_uart_class_init
,
1338 /* Synchronous Serial Ports */
1340 #define TYPE_STRONGARM_SSP "strongarm-ssp"
1341 #define STRONGARM_SSP(obj) \
1342 OBJECT_CHECK(StrongARMSSPState, (obj), TYPE_STRONGARM_SSP)
1344 typedef struct StrongARMSSPState
{
1345 SysBusDevice parent_obj
;
1354 uint16_t rx_fifo
[8];
1357 } StrongARMSSPState
;
1359 #define SSCR0 0x60 /* SSP Control register 0 */
1360 #define SSCR1 0x64 /* SSP Control register 1 */
1361 #define SSDR 0x6c /* SSP Data register */
1362 #define SSSR 0x74 /* SSP Status register */
1364 /* Bitfields for above registers */
1365 #define SSCR0_SPI(x) (((x) & 0x30) == 0x00)
1366 #define SSCR0_SSP(x) (((x) & 0x30) == 0x10)
1367 #define SSCR0_UWIRE(x) (((x) & 0x30) == 0x20)
1368 #define SSCR0_PSP(x) (((x) & 0x30) == 0x30)
1369 #define SSCR0_SSE (1 << 7)
1370 #define SSCR0_DSS(x) (((x) & 0xf) + 1)
1371 #define SSCR1_RIE (1 << 0)
1372 #define SSCR1_TIE (1 << 1)
1373 #define SSCR1_LBM (1 << 2)
1374 #define SSSR_TNF (1 << 2)
1375 #define SSSR_RNE (1 << 3)
1376 #define SSSR_TFS (1 << 5)
1377 #define SSSR_RFS (1 << 6)
1378 #define SSSR_ROR (1 << 7)
1379 #define SSSR_RW 0x0080
1381 static void strongarm_ssp_int_update(StrongARMSSPState
*s
)
1385 level
|= (s
->sssr
& SSSR_ROR
);
1386 level
|= (s
->sssr
& SSSR_RFS
) && (s
->sscr
[1] & SSCR1_RIE
);
1387 level
|= (s
->sssr
& SSSR_TFS
) && (s
->sscr
[1] & SSCR1_TIE
);
1388 qemu_set_irq(s
->irq
, level
);
1391 static void strongarm_ssp_fifo_update(StrongARMSSPState
*s
)
1393 s
->sssr
&= ~SSSR_TFS
;
1394 s
->sssr
&= ~SSSR_TNF
;
1395 if (s
->sscr
[0] & SSCR0_SSE
) {
1396 if (s
->rx_level
>= 4) {
1397 s
->sssr
|= SSSR_RFS
;
1399 s
->sssr
&= ~SSSR_RFS
;
1402 s
->sssr
|= SSSR_RNE
;
1404 s
->sssr
&= ~SSSR_RNE
;
1406 /* TX FIFO is never filled, so it is always in underrun
1407 condition if SSP is enabled */
1408 s
->sssr
|= SSSR_TFS
;
1409 s
->sssr
|= SSSR_TNF
;
1412 strongarm_ssp_int_update(s
);
1415 static uint64_t strongarm_ssp_read(void *opaque
, hwaddr addr
,
1418 StrongARMSSPState
*s
= opaque
;
1429 if (~s
->sscr
[0] & SSCR0_SSE
) {
1432 if (s
->rx_level
< 1) {
1433 printf("%s: SSP Rx Underrun\n", __func__
);
1437 retval
= s
->rx_fifo
[s
->rx_start
++];
1439 strongarm_ssp_fifo_update(s
);
1442 printf("%s: Bad register 0x" TARGET_FMT_plx
"\n", __func__
, addr
);
1448 static void strongarm_ssp_write(void *opaque
, hwaddr addr
,
1449 uint64_t value
, unsigned size
)
1451 StrongARMSSPState
*s
= opaque
;
1455 s
->sscr
[0] = value
& 0xffbf;
1456 if ((s
->sscr
[0] & SSCR0_SSE
) && SSCR0_DSS(value
) < 4) {
1457 printf("%s: Wrong data size: %i bits\n", __func__
,
1458 (int)SSCR0_DSS(value
));
1460 if (!(value
& SSCR0_SSE
)) {
1464 strongarm_ssp_fifo_update(s
);
1468 s
->sscr
[1] = value
& 0x2f;
1469 if (value
& SSCR1_LBM
) {
1470 printf("%s: Attempt to use SSP LBM mode\n", __func__
);
1472 strongarm_ssp_fifo_update(s
);
1476 s
->sssr
&= ~(value
& SSSR_RW
);
1477 strongarm_ssp_int_update(s
);
1481 if (SSCR0_UWIRE(s
->sscr
[0])) {
1484 /* Note how 32bits overflow does no harm here */
1485 value
&= (1 << SSCR0_DSS(s
->sscr
[0])) - 1;
1487 /* Data goes from here to the Tx FIFO and is shifted out from
1488 * there directly to the slave, no need to buffer it.
1490 if (s
->sscr
[0] & SSCR0_SSE
) {
1492 if (s
->sscr
[1] & SSCR1_LBM
) {
1495 readval
= ssi_transfer(s
->bus
, value
);
1498 if (s
->rx_level
< 0x08) {
1499 s
->rx_fifo
[(s
->rx_start
+ s
->rx_level
++) & 0x7] = readval
;
1501 s
->sssr
|= SSSR_ROR
;
1504 strongarm_ssp_fifo_update(s
);
1508 printf("%s: Bad register 0x" TARGET_FMT_plx
"\n", __func__
, addr
);
1513 static const MemoryRegionOps strongarm_ssp_ops
= {
1514 .read
= strongarm_ssp_read
,
1515 .write
= strongarm_ssp_write
,
1516 .endianness
= DEVICE_NATIVE_ENDIAN
,
1519 static int strongarm_ssp_post_load(void *opaque
, int version_id
)
1521 StrongARMSSPState
*s
= opaque
;
1523 strongarm_ssp_fifo_update(s
);
1528 static void strongarm_ssp_init(Object
*obj
)
1530 SysBusDevice
*sbd
= SYS_BUS_DEVICE(obj
);
1531 DeviceState
*dev
= DEVICE(sbd
);
1532 StrongARMSSPState
*s
= STRONGARM_SSP(dev
);
1534 sysbus_init_irq(sbd
, &s
->irq
);
1536 memory_region_init_io(&s
->iomem
, obj
, &strongarm_ssp_ops
, s
,
1538 sysbus_init_mmio(sbd
, &s
->iomem
);
1540 s
->bus
= ssi_create_bus(dev
, "ssi");
1543 static void strongarm_ssp_reset(DeviceState
*dev
)
1545 StrongARMSSPState
*s
= STRONGARM_SSP(dev
);
1547 s
->sssr
= 0x03; /* 3 bit data, SPI, disabled */
1552 static const VMStateDescription vmstate_strongarm_ssp_regs
= {
1553 .name
= "strongarm-ssp",
1555 .minimum_version_id
= 0,
1556 .post_load
= strongarm_ssp_post_load
,
1557 .fields
= (VMStateField
[]) {
1558 VMSTATE_UINT16_ARRAY(sscr
, StrongARMSSPState
, 2),
1559 VMSTATE_UINT16(sssr
, StrongARMSSPState
),
1560 VMSTATE_UINT16_ARRAY(rx_fifo
, StrongARMSSPState
, 8),
1561 VMSTATE_UINT8(rx_start
, StrongARMSSPState
),
1562 VMSTATE_UINT8(rx_level
, StrongARMSSPState
),
1563 VMSTATE_END_OF_LIST(),
1567 static void strongarm_ssp_class_init(ObjectClass
*klass
, void *data
)
1569 DeviceClass
*dc
= DEVICE_CLASS(klass
);
1571 dc
->desc
= "StrongARM SSP controller";
1572 dc
->reset
= strongarm_ssp_reset
;
1573 dc
->vmsd
= &vmstate_strongarm_ssp_regs
;
1576 static const TypeInfo strongarm_ssp_info
= {
1577 .name
= TYPE_STRONGARM_SSP
,
1578 .parent
= TYPE_SYS_BUS_DEVICE
,
1579 .instance_size
= sizeof(StrongARMSSPState
),
1580 .instance_init
= strongarm_ssp_init
,
1581 .class_init
= strongarm_ssp_class_init
,
1584 /* Main CPU functions */
1585 StrongARMState
*sa1110_init(MemoryRegion
*sysmem
,
1586 unsigned int sdram_size
, const char *cpu_type
)
1591 s
= g_new0(StrongARMState
, 1);
1593 if (strncmp(cpu_type
, "sa1110", 6)) {
1594 error_report("Machine requires a SA1110 processor.");
1598 s
->cpu
= ARM_CPU(cpu_create(cpu_type
));
1600 memory_region_allocate_system_memory(&s
->sdram
, NULL
, "strongarm.sdram",
1602 memory_region_add_subregion(sysmem
, SA_SDCS0
, &s
->sdram
);
1604 s
->pic
= sysbus_create_varargs("strongarm_pic", 0x90050000,
1605 qdev_get_gpio_in(DEVICE(s
->cpu
), ARM_CPU_IRQ
),
1606 qdev_get_gpio_in(DEVICE(s
->cpu
), ARM_CPU_FIQ
),
1609 sysbus_create_varargs("pxa25x-timer", 0x90000000,
1610 qdev_get_gpio_in(s
->pic
, SA_PIC_OSTC0
),
1611 qdev_get_gpio_in(s
->pic
, SA_PIC_OSTC1
),
1612 qdev_get_gpio_in(s
->pic
, SA_PIC_OSTC2
),
1613 qdev_get_gpio_in(s
->pic
, SA_PIC_OSTC3
),
1616 sysbus_create_simple(TYPE_STRONGARM_RTC
, 0x90010000,
1617 qdev_get_gpio_in(s
->pic
, SA_PIC_RTC_ALARM
));
1619 s
->gpio
= strongarm_gpio_init(0x90040000, s
->pic
);
1621 s
->ppc
= sysbus_create_varargs(TYPE_STRONGARM_PPC
, 0x90060000, NULL
);
1623 for (i
= 0; sa_serial
[i
].io_base
; i
++) {
1624 DeviceState
*dev
= qdev_create(NULL
, TYPE_STRONGARM_UART
);
1625 qdev_prop_set_chr(dev
, "chardev", serial_hd(i
));
1626 qdev_init_nofail(dev
);
1627 sysbus_mmio_map(SYS_BUS_DEVICE(dev
), 0,
1628 sa_serial
[i
].io_base
);
1629 sysbus_connect_irq(SYS_BUS_DEVICE(dev
), 0,
1630 qdev_get_gpio_in(s
->pic
, sa_serial
[i
].irq
));
1633 s
->ssp
= sysbus_create_varargs(TYPE_STRONGARM_SSP
, 0x80070000,
1634 qdev_get_gpio_in(s
->pic
, SA_PIC_SSP
), NULL
);
1635 s
->ssp_bus
= (SSIBus
*)qdev_get_child_bus(s
->ssp
, "ssi");
1640 static void strongarm_register_types(void)
1642 type_register_static(&strongarm_pic_info
);
1643 type_register_static(&strongarm_rtc_sysbus_info
);
1644 type_register_static(&strongarm_gpio_info
);
1645 type_register_static(&strongarm_ppc_info
);
1646 type_register_static(&strongarm_uart_info
);
1647 type_register_static(&strongarm_ssp_info
);
1650 type_init(strongarm_register_types
)