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"
31 #include "qemu-common.h"
33 #include "hw/boards.h"
34 #include "hw/sysbus.h"
35 #include "strongarm.h"
36 #include "qemu/error-report.h"
37 #include "hw/arm/boot.h"
38 #include "chardev/char-fe.h"
39 #include "chardev/char-serial.h"
40 #include "sysemu/sysemu.h"
41 #include "hw/ssi/ssi.h"
42 #include "qemu/cutils.h"
49 - Implement cp15, c14 ?
50 - Implement cp15, c15 !!! (idle used in L)
51 - Implement idle mode handling/DIM
52 - Implement sleep mode/Wake sources
53 - Implement reset control
54 - Implement memory control regs
56 - Maybe support MBGNT/MBREQ
61 - Enhance UART with modem signals
65 # define DPRINTF(format, ...) printf(format , ## __VA_ARGS__)
67 # define DPRINTF(format, ...) do { } while (0)
74 { 0x80010000, SA_PIC_UART1
},
75 { 0x80030000, SA_PIC_UART2
},
76 { 0x80050000, SA_PIC_UART3
},
80 /* Interrupt Controller */
82 #define TYPE_STRONGARM_PIC "strongarm_pic"
83 #define STRONGARM_PIC(obj) \
84 OBJECT_CHECK(StrongARMPICState, (obj), TYPE_STRONGARM_PIC)
86 typedef struct StrongARMPICState
{
87 SysBusDevice parent_obj
;
106 #define SA_PIC_SRCS 32
109 static void strongarm_pic_update(void *opaque
)
111 StrongARMPICState
*s
= opaque
;
113 /* FIXME: reflect DIM */
114 qemu_set_irq(s
->fiq
, s
->pending
& s
->enabled
& s
->is_fiq
);
115 qemu_set_irq(s
->irq
, s
->pending
& s
->enabled
& ~s
->is_fiq
);
118 static void strongarm_pic_set_irq(void *opaque
, int irq
, int level
)
120 StrongARMPICState
*s
= opaque
;
123 s
->pending
|= 1 << irq
;
125 s
->pending
&= ~(1 << irq
);
128 strongarm_pic_update(s
);
131 static uint64_t strongarm_pic_mem_read(void *opaque
, hwaddr offset
,
134 StrongARMPICState
*s
= opaque
;
138 return s
->pending
& ~s
->is_fiq
& s
->enabled
;
144 return s
->int_idle
== 0;
146 return s
->pending
& s
->is_fiq
& s
->enabled
;
150 printf("%s: Bad register offset 0x" TARGET_FMT_plx
"\n",
156 static void strongarm_pic_mem_write(void *opaque
, hwaddr offset
,
157 uint64_t value
, unsigned size
)
159 StrongARMPICState
*s
= opaque
;
169 s
->int_idle
= (value
& 1) ? 0 : ~0;
172 printf("%s: Bad register offset 0x" TARGET_FMT_plx
"\n",
176 strongarm_pic_update(s
);
179 static const MemoryRegionOps strongarm_pic_ops
= {
180 .read
= strongarm_pic_mem_read
,
181 .write
= strongarm_pic_mem_write
,
182 .endianness
= DEVICE_NATIVE_ENDIAN
,
185 static void strongarm_pic_initfn(Object
*obj
)
187 DeviceState
*dev
= DEVICE(obj
);
188 StrongARMPICState
*s
= STRONGARM_PIC(obj
);
189 SysBusDevice
*sbd
= SYS_BUS_DEVICE(obj
);
191 qdev_init_gpio_in(dev
, strongarm_pic_set_irq
, SA_PIC_SRCS
);
192 memory_region_init_io(&s
->iomem
, obj
, &strongarm_pic_ops
, s
,
194 sysbus_init_mmio(sbd
, &s
->iomem
);
195 sysbus_init_irq(sbd
, &s
->irq
);
196 sysbus_init_irq(sbd
, &s
->fiq
);
199 static int strongarm_pic_post_load(void *opaque
, int version_id
)
201 strongarm_pic_update(opaque
);
205 static VMStateDescription vmstate_strongarm_pic_regs
= {
206 .name
= "strongarm_pic",
208 .minimum_version_id
= 0,
209 .post_load
= strongarm_pic_post_load
,
210 .fields
= (VMStateField
[]) {
211 VMSTATE_UINT32(pending
, StrongARMPICState
),
212 VMSTATE_UINT32(enabled
, StrongARMPICState
),
213 VMSTATE_UINT32(is_fiq
, StrongARMPICState
),
214 VMSTATE_UINT32(int_idle
, StrongARMPICState
),
215 VMSTATE_END_OF_LIST(),
219 static void strongarm_pic_class_init(ObjectClass
*klass
, void *data
)
221 DeviceClass
*dc
= DEVICE_CLASS(klass
);
223 dc
->desc
= "StrongARM PIC";
224 dc
->vmsd
= &vmstate_strongarm_pic_regs
;
227 static const TypeInfo strongarm_pic_info
= {
228 .name
= TYPE_STRONGARM_PIC
,
229 .parent
= TYPE_SYS_BUS_DEVICE
,
230 .instance_size
= sizeof(StrongARMPICState
),
231 .instance_init
= strongarm_pic_initfn
,
232 .class_init
= strongarm_pic_class_init
,
235 /* Real-Time Clock */
236 #define RTAR 0x00 /* RTC Alarm register */
237 #define RCNR 0x04 /* RTC Counter register */
238 #define RTTR 0x08 /* RTC Timer Trim register */
239 #define RTSR 0x10 /* RTC Status register */
241 #define RTSR_AL (1 << 0) /* RTC Alarm detected */
242 #define RTSR_HZ (1 << 1) /* RTC 1Hz detected */
243 #define RTSR_ALE (1 << 2) /* RTC Alarm enable */
244 #define RTSR_HZE (1 << 3) /* RTC 1Hz enable */
246 /* 16 LSB of RTTR are clockdiv for internal trim logic,
247 * trim delete isn't emulated, so
248 * f = 32 768 / (RTTR_trim + 1) */
250 #define TYPE_STRONGARM_RTC "strongarm-rtc"
251 #define STRONGARM_RTC(obj) \
252 OBJECT_CHECK(StrongARMRTCState, (obj), TYPE_STRONGARM_RTC)
254 typedef struct StrongARMRTCState
{
255 SysBusDevice parent_obj
;
263 QEMUTimer
*rtc_alarm
;
269 static inline void strongarm_rtc_int_update(StrongARMRTCState
*s
)
271 qemu_set_irq(s
->rtc_irq
, s
->rtsr
& RTSR_AL
);
272 qemu_set_irq(s
->rtc_hz_irq
, s
->rtsr
& RTSR_HZ
);
275 static void strongarm_rtc_hzupdate(StrongARMRTCState
*s
)
277 int64_t rt
= qemu_clock_get_ms(rtc_clock
);
278 s
->last_rcnr
+= ((rt
- s
->last_hz
) << 15) /
279 (1000 * ((s
->rttr
& 0xffff) + 1));
283 static inline void strongarm_rtc_timer_update(StrongARMRTCState
*s
)
285 if ((s
->rtsr
& RTSR_HZE
) && !(s
->rtsr
& RTSR_HZ
)) {
286 timer_mod(s
->rtc_hz
, s
->last_hz
+ 1000);
288 timer_del(s
->rtc_hz
);
291 if ((s
->rtsr
& RTSR_ALE
) && !(s
->rtsr
& RTSR_AL
)) {
292 timer_mod(s
->rtc_alarm
, s
->last_hz
+
293 (((s
->rtar
- s
->last_rcnr
) * 1000 *
294 ((s
->rttr
& 0xffff) + 1)) >> 15));
296 timer_del(s
->rtc_alarm
);
300 static inline void strongarm_rtc_alarm_tick(void *opaque
)
302 StrongARMRTCState
*s
= opaque
;
304 strongarm_rtc_timer_update(s
);
305 strongarm_rtc_int_update(s
);
308 static inline void strongarm_rtc_hz_tick(void *opaque
)
310 StrongARMRTCState
*s
= opaque
;
312 strongarm_rtc_timer_update(s
);
313 strongarm_rtc_int_update(s
);
316 static uint64_t strongarm_rtc_read(void *opaque
, hwaddr addr
,
319 StrongARMRTCState
*s
= opaque
;
329 return s
->last_rcnr
+
330 ((qemu_clock_get_ms(rtc_clock
) - s
->last_hz
) << 15) /
331 (1000 * ((s
->rttr
& 0xffff) + 1));
333 printf("%s: Bad register 0x" TARGET_FMT_plx
"\n", __func__
, addr
);
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 printf("%s: Bad register 0x" TARGET_FMT_plx
"\n", __func__
, addr
);
379 static const MemoryRegionOps strongarm_rtc_ops
= {
380 .read
= strongarm_rtc_read
,
381 .write
= strongarm_rtc_write
,
382 .endianness
= DEVICE_NATIVE_ENDIAN
,
385 static void strongarm_rtc_init(Object
*obj
)
387 StrongARMRTCState
*s
= STRONGARM_RTC(obj
);
388 SysBusDevice
*dev
= SYS_BUS_DEVICE(obj
);
394 qemu_get_timedate(&tm
, 0);
396 s
->last_rcnr
= (uint32_t) mktimegm(&tm
);
397 s
->last_hz
= qemu_clock_get_ms(rtc_clock
);
399 s
->rtc_alarm
= timer_new_ms(rtc_clock
, strongarm_rtc_alarm_tick
, s
);
400 s
->rtc_hz
= timer_new_ms(rtc_clock
, strongarm_rtc_hz_tick
, s
);
402 sysbus_init_irq(dev
, &s
->rtc_irq
);
403 sysbus_init_irq(dev
, &s
->rtc_hz_irq
);
405 memory_region_init_io(&s
->iomem
, obj
, &strongarm_rtc_ops
, s
,
407 sysbus_init_mmio(dev
, &s
->iomem
);
410 static int strongarm_rtc_pre_save(void *opaque
)
412 StrongARMRTCState
*s
= opaque
;
414 strongarm_rtc_hzupdate(s
);
419 static int strongarm_rtc_post_load(void *opaque
, int version_id
)
421 StrongARMRTCState
*s
= opaque
;
423 strongarm_rtc_timer_update(s
);
424 strongarm_rtc_int_update(s
);
429 static const VMStateDescription vmstate_strongarm_rtc_regs
= {
430 .name
= "strongarm-rtc",
432 .minimum_version_id
= 0,
433 .pre_save
= strongarm_rtc_pre_save
,
434 .post_load
= strongarm_rtc_post_load
,
435 .fields
= (VMStateField
[]) {
436 VMSTATE_UINT32(rttr
, StrongARMRTCState
),
437 VMSTATE_UINT32(rtsr
, StrongARMRTCState
),
438 VMSTATE_UINT32(rtar
, StrongARMRTCState
),
439 VMSTATE_UINT32(last_rcnr
, StrongARMRTCState
),
440 VMSTATE_INT64(last_hz
, StrongARMRTCState
),
441 VMSTATE_END_OF_LIST(),
445 static void strongarm_rtc_sysbus_class_init(ObjectClass
*klass
, void *data
)
447 DeviceClass
*dc
= DEVICE_CLASS(klass
);
449 dc
->desc
= "StrongARM RTC Controller";
450 dc
->vmsd
= &vmstate_strongarm_rtc_regs
;
453 static const TypeInfo strongarm_rtc_sysbus_info
= {
454 .name
= TYPE_STRONGARM_RTC
,
455 .parent
= TYPE_SYS_BUS_DEVICE
,
456 .instance_size
= sizeof(StrongARMRTCState
),
457 .instance_init
= strongarm_rtc_init
,
458 .class_init
= strongarm_rtc_sysbus_class_init
,
471 #define TYPE_STRONGARM_GPIO "strongarm-gpio"
472 #define STRONGARM_GPIO(obj) \
473 OBJECT_CHECK(StrongARMGPIOInfo, (obj), TYPE_STRONGARM_GPIO)
475 typedef struct StrongARMGPIOInfo StrongARMGPIOInfo
;
476 struct StrongARMGPIOInfo
{
479 qemu_irq handler
[28];
495 static void strongarm_gpio_irq_update(StrongARMGPIOInfo
*s
)
498 for (i
= 0; i
< 11; i
++) {
499 qemu_set_irq(s
->irqs
[i
], s
->status
& (1 << i
));
502 qemu_set_irq(s
->irqX
, (s
->status
& ~0x7ff));
505 static void strongarm_gpio_set(void *opaque
, int line
, int level
)
507 StrongARMGPIOInfo
*s
= opaque
;
513 s
->status
|= s
->rising
& mask
&
514 ~s
->ilevel
& ~s
->dir
;
517 s
->status
|= s
->falling
& mask
&
522 if (s
->status
& mask
) {
523 strongarm_gpio_irq_update(s
);
527 static void strongarm_gpio_handler_update(StrongARMGPIOInfo
*s
)
529 uint32_t level
, diff
;
532 level
= s
->olevel
& s
->dir
;
534 for (diff
= s
->prev_level
^ level
; diff
; diff
^= 1 << bit
) {
536 qemu_set_irq(s
->handler
[bit
], (level
>> bit
) & 1);
539 s
->prev_level
= level
;
542 static uint64_t strongarm_gpio_read(void *opaque
, hwaddr offset
,
545 StrongARMGPIOInfo
*s
= opaque
;
548 case GPDR
: /* GPIO Pin-Direction registers */
551 case GPSR
: /* GPIO Pin-Output Set registers */
552 qemu_log_mask(LOG_GUEST_ERROR
,
553 "strongarm GPIO: read from write only register GPSR\n");
556 case GPCR
: /* GPIO Pin-Output Clear registers */
557 qemu_log_mask(LOG_GUEST_ERROR
,
558 "strongarm GPIO: read from write only register GPCR\n");
561 case GRER
: /* GPIO Rising-Edge Detect Enable registers */
564 case GFER
: /* GPIO Falling-Edge Detect Enable registers */
567 case GAFR
: /* GPIO Alternate Function registers */
570 case GPLR
: /* GPIO Pin-Level registers */
571 return (s
->olevel
& s
->dir
) |
572 (s
->ilevel
& ~s
->dir
);
574 case GEDR
: /* GPIO Edge Detect Status registers */
578 printf("%s: Bad offset 0x" TARGET_FMT_plx
"\n", __func__
, offset
);
584 static void strongarm_gpio_write(void *opaque
, hwaddr offset
,
585 uint64_t value
, unsigned size
)
587 StrongARMGPIOInfo
*s
= opaque
;
590 case GPDR
: /* GPIO Pin-Direction registers */
591 s
->dir
= value
& 0x0fffffff;
592 strongarm_gpio_handler_update(s
);
595 case GPSR
: /* GPIO Pin-Output Set registers */
596 s
->olevel
|= value
& 0x0fffffff;
597 strongarm_gpio_handler_update(s
);
600 case GPCR
: /* GPIO Pin-Output Clear registers */
602 strongarm_gpio_handler_update(s
);
605 case GRER
: /* GPIO Rising-Edge Detect Enable registers */
609 case GFER
: /* GPIO Falling-Edge Detect Enable registers */
613 case GAFR
: /* GPIO Alternate Function registers */
617 case GEDR
: /* GPIO Edge Detect Status registers */
619 strongarm_gpio_irq_update(s
);
623 printf("%s: Bad offset 0x" TARGET_FMT_plx
"\n", __func__
, offset
);
627 static const MemoryRegionOps strongarm_gpio_ops
= {
628 .read
= strongarm_gpio_read
,
629 .write
= strongarm_gpio_write
,
630 .endianness
= DEVICE_NATIVE_ENDIAN
,
633 static DeviceState
*strongarm_gpio_init(hwaddr base
,
639 dev
= qdev_create(NULL
, TYPE_STRONGARM_GPIO
);
640 qdev_init_nofail(dev
);
642 sysbus_mmio_map(SYS_BUS_DEVICE(dev
), 0, base
);
643 for (i
= 0; i
< 12; i
++)
644 sysbus_connect_irq(SYS_BUS_DEVICE(dev
), i
,
645 qdev_get_gpio_in(pic
, SA_PIC_GPIO0_EDGE
+ i
));
650 static void strongarm_gpio_initfn(Object
*obj
)
652 DeviceState
*dev
= DEVICE(obj
);
653 StrongARMGPIOInfo
*s
= STRONGARM_GPIO(obj
);
654 SysBusDevice
*sbd
= SYS_BUS_DEVICE(obj
);
657 qdev_init_gpio_in(dev
, strongarm_gpio_set
, 28);
658 qdev_init_gpio_out(dev
, s
->handler
, 28);
660 memory_region_init_io(&s
->iomem
, obj
, &strongarm_gpio_ops
, s
,
663 sysbus_init_mmio(sbd
, &s
->iomem
);
664 for (i
= 0; i
< 11; i
++) {
665 sysbus_init_irq(sbd
, &s
->irqs
[i
]);
667 sysbus_init_irq(sbd
, &s
->irqX
);
670 static const VMStateDescription vmstate_strongarm_gpio_regs
= {
671 .name
= "strongarm-gpio",
673 .minimum_version_id
= 0,
674 .fields
= (VMStateField
[]) {
675 VMSTATE_UINT32(ilevel
, StrongARMGPIOInfo
),
676 VMSTATE_UINT32(olevel
, StrongARMGPIOInfo
),
677 VMSTATE_UINT32(dir
, StrongARMGPIOInfo
),
678 VMSTATE_UINT32(rising
, StrongARMGPIOInfo
),
679 VMSTATE_UINT32(falling
, StrongARMGPIOInfo
),
680 VMSTATE_UINT32(status
, StrongARMGPIOInfo
),
681 VMSTATE_UINT32(gafr
, StrongARMGPIOInfo
),
682 VMSTATE_UINT32(prev_level
, StrongARMGPIOInfo
),
683 VMSTATE_END_OF_LIST(),
687 static void strongarm_gpio_class_init(ObjectClass
*klass
, void *data
)
689 DeviceClass
*dc
= DEVICE_CLASS(klass
);
691 dc
->desc
= "StrongARM GPIO controller";
692 dc
->vmsd
= &vmstate_strongarm_gpio_regs
;
695 static const TypeInfo strongarm_gpio_info
= {
696 .name
= TYPE_STRONGARM_GPIO
,
697 .parent
= TYPE_SYS_BUS_DEVICE
,
698 .instance_size
= sizeof(StrongARMGPIOInfo
),
699 .instance_init
= strongarm_gpio_initfn
,
700 .class_init
= strongarm_gpio_class_init
,
703 /* Peripheral Pin Controller */
710 #define TYPE_STRONGARM_PPC "strongarm-ppc"
711 #define STRONGARM_PPC(obj) \
712 OBJECT_CHECK(StrongARMPPCInfo, (obj), TYPE_STRONGARM_PPC)
714 typedef struct StrongARMPPCInfo StrongARMPPCInfo
;
715 struct StrongARMPPCInfo
{
716 SysBusDevice parent_obj
;
719 qemu_irq handler
[28];
731 static void strongarm_ppc_set(void *opaque
, int line
, int level
)
733 StrongARMPPCInfo
*s
= opaque
;
736 s
->ilevel
|= 1 << line
;
738 s
->ilevel
&= ~(1 << line
);
742 static void strongarm_ppc_handler_update(StrongARMPPCInfo
*s
)
744 uint32_t level
, diff
;
747 level
= s
->olevel
& s
->dir
;
749 for (diff
= s
->prev_level
^ level
; diff
; diff
^= 1 << bit
) {
751 qemu_set_irq(s
->handler
[bit
], (level
>> bit
) & 1);
754 s
->prev_level
= level
;
757 static uint64_t strongarm_ppc_read(void *opaque
, hwaddr offset
,
760 StrongARMPPCInfo
*s
= opaque
;
763 case PPDR
: /* PPC Pin Direction registers */
764 return s
->dir
| ~0x3fffff;
766 case PPSR
: /* PPC Pin State registers */
767 return (s
->olevel
& s
->dir
) |
768 (s
->ilevel
& ~s
->dir
) |
772 return s
->ppar
| ~0x41000;
778 return s
->ppfr
| ~0x7f001;
781 printf("%s: Bad offset 0x" TARGET_FMT_plx
"\n", __func__
, offset
);
787 static void strongarm_ppc_write(void *opaque
, hwaddr offset
,
788 uint64_t value
, unsigned size
)
790 StrongARMPPCInfo
*s
= opaque
;
793 case PPDR
: /* PPC Pin Direction registers */
794 s
->dir
= value
& 0x3fffff;
795 strongarm_ppc_handler_update(s
);
798 case PPSR
: /* PPC Pin State registers */
799 s
->olevel
= value
& s
->dir
& 0x3fffff;
800 strongarm_ppc_handler_update(s
);
804 s
->ppar
= value
& 0x41000;
808 s
->psdr
= value
& 0x3fffff;
812 s
->ppfr
= value
& 0x7f001;
816 printf("%s: Bad offset 0x" TARGET_FMT_plx
"\n", __func__
, offset
);
820 static const MemoryRegionOps strongarm_ppc_ops
= {
821 .read
= strongarm_ppc_read
,
822 .write
= strongarm_ppc_write
,
823 .endianness
= DEVICE_NATIVE_ENDIAN
,
826 static void strongarm_ppc_init(Object
*obj
)
828 DeviceState
*dev
= DEVICE(obj
);
829 StrongARMPPCInfo
*s
= STRONGARM_PPC(obj
);
830 SysBusDevice
*sbd
= SYS_BUS_DEVICE(obj
);
832 qdev_init_gpio_in(dev
, strongarm_ppc_set
, 22);
833 qdev_init_gpio_out(dev
, s
->handler
, 22);
835 memory_region_init_io(&s
->iomem
, obj
, &strongarm_ppc_ops
, s
,
838 sysbus_init_mmio(sbd
, &s
->iomem
);
841 static const VMStateDescription vmstate_strongarm_ppc_regs
= {
842 .name
= "strongarm-ppc",
844 .minimum_version_id
= 0,
845 .fields
= (VMStateField
[]) {
846 VMSTATE_UINT32(ilevel
, StrongARMPPCInfo
),
847 VMSTATE_UINT32(olevel
, StrongARMPPCInfo
),
848 VMSTATE_UINT32(dir
, StrongARMPPCInfo
),
849 VMSTATE_UINT32(ppar
, StrongARMPPCInfo
),
850 VMSTATE_UINT32(psdr
, StrongARMPPCInfo
),
851 VMSTATE_UINT32(ppfr
, StrongARMPPCInfo
),
852 VMSTATE_UINT32(prev_level
, StrongARMPPCInfo
),
853 VMSTATE_END_OF_LIST(),
857 static void strongarm_ppc_class_init(ObjectClass
*klass
, void *data
)
859 DeviceClass
*dc
= DEVICE_CLASS(klass
);
861 dc
->desc
= "StrongARM PPC controller";
862 dc
->vmsd
= &vmstate_strongarm_ppc_regs
;
865 static const TypeInfo strongarm_ppc_info
= {
866 .name
= TYPE_STRONGARM_PPC
,
867 .parent
= TYPE_SYS_BUS_DEVICE
,
868 .instance_size
= sizeof(StrongARMPPCInfo
),
869 .instance_init
= strongarm_ppc_init
,
870 .class_init
= strongarm_ppc_class_init
,
882 #define UTCR0_PE (1 << 0) /* Parity enable */
883 #define UTCR0_OES (1 << 1) /* Even parity */
884 #define UTCR0_SBS (1 << 2) /* 2 stop bits */
885 #define UTCR0_DSS (1 << 3) /* 8-bit data */
887 #define UTCR3_RXE (1 << 0) /* Rx enable */
888 #define UTCR3_TXE (1 << 1) /* Tx enable */
889 #define UTCR3_BRK (1 << 2) /* Force Break */
890 #define UTCR3_RIE (1 << 3) /* Rx int enable */
891 #define UTCR3_TIE (1 << 4) /* Tx int enable */
892 #define UTCR3_LBM (1 << 5) /* Loopback */
894 #define UTSR0_TFS (1 << 0) /* Tx FIFO nearly empty */
895 #define UTSR0_RFS (1 << 1) /* Rx FIFO nearly full */
896 #define UTSR0_RID (1 << 2) /* Receiver Idle */
897 #define UTSR0_RBB (1 << 3) /* Receiver begin break */
898 #define UTSR0_REB (1 << 4) /* Receiver end break */
899 #define UTSR0_EIF (1 << 5) /* Error in FIFO */
901 #define UTSR1_RNE (1 << 1) /* Receive FIFO not empty */
902 #define UTSR1_TNF (1 << 2) /* Transmit FIFO not full */
903 #define UTSR1_PRE (1 << 3) /* Parity error */
904 #define UTSR1_FRE (1 << 4) /* Frame error */
905 #define UTSR1_ROR (1 << 5) /* Receive Over Run */
907 #define RX_FIFO_PRE (1 << 8)
908 #define RX_FIFO_FRE (1 << 9)
909 #define RX_FIFO_ROR (1 << 10)
911 #define TYPE_STRONGARM_UART "strongarm-uart"
912 #define STRONGARM_UART(obj) \
913 OBJECT_CHECK(StrongARMUARTState, (obj), TYPE_STRONGARM_UART)
915 typedef struct StrongARMUARTState
{
916 SysBusDevice parent_obj
;
931 uint16_t rx_fifo
[12]; /* value + error flags in high bits */
935 uint64_t char_transmit_time
; /* time to transmit a char in ticks*/
937 QEMUTimer
*rx_timeout_timer
;
939 } StrongARMUARTState
;
941 static void strongarm_uart_update_status(StrongARMUARTState
*s
)
945 if (s
->tx_len
!= 8) {
949 if (s
->rx_len
!= 0) {
950 uint16_t ent
= s
->rx_fifo
[s
->rx_start
];
953 if (ent
& RX_FIFO_PRE
) {
954 s
->utsr1
|= UTSR1_PRE
;
956 if (ent
& RX_FIFO_FRE
) {
957 s
->utsr1
|= UTSR1_FRE
;
959 if (ent
& RX_FIFO_ROR
) {
960 s
->utsr1
|= UTSR1_ROR
;
967 static void strongarm_uart_update_int_status(StrongARMUARTState
*s
)
969 uint16_t utsr0
= s
->utsr0
&
970 (UTSR0_REB
| UTSR0_RBB
| UTSR0_RID
);
973 if ((s
->utcr3
& UTCR3_TXE
) &&
974 (s
->utcr3
& UTCR3_TIE
) &&
979 if ((s
->utcr3
& UTCR3_RXE
) &&
980 (s
->utcr3
& UTCR3_RIE
) &&
985 for (i
= 0; i
< s
->rx_len
&& i
< 4; i
++)
986 if (s
->rx_fifo
[(s
->rx_start
+ i
) % 12] & ~0xff) {
992 qemu_set_irq(s
->irq
, utsr0
);
995 static void strongarm_uart_update_parameters(StrongARMUARTState
*s
)
997 int speed
, parity
, data_bits
, stop_bits
, frame_size
;
998 QEMUSerialSetParams ssp
;
1002 if (s
->utcr0
& UTCR0_PE
) {
1005 if (s
->utcr0
& UTCR0_OES
) {
1013 if (s
->utcr0
& UTCR0_SBS
) {
1019 data_bits
= (s
->utcr0
& UTCR0_DSS
) ? 8 : 7;
1020 frame_size
+= data_bits
+ stop_bits
;
1021 speed
= 3686400 / 16 / (s
->brd
+ 1);
1023 ssp
.parity
= parity
;
1024 ssp
.data_bits
= data_bits
;
1025 ssp
.stop_bits
= stop_bits
;
1026 s
->char_transmit_time
= (NANOSECONDS_PER_SECOND
/ speed
) * frame_size
;
1027 qemu_chr_fe_ioctl(&s
->chr
, CHR_IOCTL_SERIAL_SET_PARAMS
, &ssp
);
1029 DPRINTF(stderr
, "%s speed=%d parity=%c data=%d stop=%d\n", s
->chr
->label
,
1030 speed
, parity
, data_bits
, stop_bits
);
1033 static void strongarm_uart_rx_to(void *opaque
)
1035 StrongARMUARTState
*s
= opaque
;
1038 s
->utsr0
|= UTSR0_RID
;
1039 strongarm_uart_update_int_status(s
);
1043 static void strongarm_uart_rx_push(StrongARMUARTState
*s
, uint16_t c
)
1045 if ((s
->utcr3
& UTCR3_RXE
) == 0) {
1050 if (s
->wait_break_end
) {
1051 s
->utsr0
|= UTSR0_REB
;
1052 s
->wait_break_end
= false;
1055 if (s
->rx_len
< 12) {
1056 s
->rx_fifo
[(s
->rx_start
+ s
->rx_len
) % 12] = c
;
1059 s
->rx_fifo
[(s
->rx_start
+ 11) % 12] |= RX_FIFO_ROR
;
1062 static int strongarm_uart_can_receive(void *opaque
)
1064 StrongARMUARTState
*s
= opaque
;
1066 if (s
->rx_len
== 12) {
1069 /* It's best not to get more than 2/3 of RX FIFO, so advertise that much */
1070 if (s
->rx_len
< 8) {
1071 return 8 - s
->rx_len
;
1076 static void strongarm_uart_receive(void *opaque
, const uint8_t *buf
, int size
)
1078 StrongARMUARTState
*s
= opaque
;
1081 for (i
= 0; i
< size
; i
++) {
1082 strongarm_uart_rx_push(s
, buf
[i
]);
1085 /* call the timeout receive callback in 3 char transmit time */
1086 timer_mod(s
->rx_timeout_timer
,
1087 qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL
) + s
->char_transmit_time
* 3);
1089 strongarm_uart_update_status(s
);
1090 strongarm_uart_update_int_status(s
);
1093 static void strongarm_uart_event(void *opaque
, int event
)
1095 StrongARMUARTState
*s
= opaque
;
1096 if (event
== CHR_EVENT_BREAK
) {
1097 s
->utsr0
|= UTSR0_RBB
;
1098 strongarm_uart_rx_push(s
, RX_FIFO_FRE
);
1099 s
->wait_break_end
= true;
1100 strongarm_uart_update_status(s
);
1101 strongarm_uart_update_int_status(s
);
1105 static void strongarm_uart_tx(void *opaque
)
1107 StrongARMUARTState
*s
= opaque
;
1108 uint64_t new_xmit_ts
= qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL
);
1110 if (s
->utcr3
& UTCR3_LBM
) /* loopback */ {
1111 strongarm_uart_receive(s
, &s
->tx_fifo
[s
->tx_start
], 1);
1112 } else if (qemu_chr_fe_backend_connected(&s
->chr
)) {
1113 /* XXX this blocks entire thread. Rewrite to use
1114 * qemu_chr_fe_write and background I/O callbacks */
1115 qemu_chr_fe_write_all(&s
->chr
, &s
->tx_fifo
[s
->tx_start
], 1);
1118 s
->tx_start
= (s
->tx_start
+ 1) % 8;
1121 timer_mod(s
->tx_timer
, new_xmit_ts
+ s
->char_transmit_time
);
1123 strongarm_uart_update_status(s
);
1124 strongarm_uart_update_int_status(s
);
1127 static uint64_t strongarm_uart_read(void *opaque
, hwaddr addr
,
1130 StrongARMUARTState
*s
= opaque
;
1141 return s
->brd
& 0xff;
1147 if (s
->rx_len
!= 0) {
1148 ret
= s
->rx_fifo
[s
->rx_start
];
1149 s
->rx_start
= (s
->rx_start
+ 1) % 12;
1151 strongarm_uart_update_status(s
);
1152 strongarm_uart_update_int_status(s
);
1164 printf("%s: Bad register 0x" TARGET_FMT_plx
"\n", __func__
, addr
);
1169 static void strongarm_uart_write(void *opaque
, hwaddr addr
,
1170 uint64_t value
, unsigned size
)
1172 StrongARMUARTState
*s
= opaque
;
1176 s
->utcr0
= value
& 0x7f;
1177 strongarm_uart_update_parameters(s
);
1181 s
->brd
= (s
->brd
& 0xff) | ((value
& 0xf) << 8);
1182 strongarm_uart_update_parameters(s
);
1186 s
->brd
= (s
->brd
& 0xf00) | (value
& 0xff);
1187 strongarm_uart_update_parameters(s
);
1191 s
->utcr3
= value
& 0x3f;
1192 if ((s
->utcr3
& UTCR3_RXE
) == 0) {
1195 if ((s
->utcr3
& UTCR3_TXE
) == 0) {
1198 strongarm_uart_update_status(s
);
1199 strongarm_uart_update_int_status(s
);
1203 if ((s
->utcr3
& UTCR3_TXE
) && s
->tx_len
!= 8) {
1204 s
->tx_fifo
[(s
->tx_start
+ s
->tx_len
) % 8] = value
;
1206 strongarm_uart_update_status(s
);
1207 strongarm_uart_update_int_status(s
);
1208 if (s
->tx_len
== 1) {
1209 strongarm_uart_tx(s
);
1215 s
->utsr0
= s
->utsr0
& ~(value
&
1216 (UTSR0_REB
| UTSR0_RBB
| UTSR0_RID
));
1217 strongarm_uart_update_int_status(s
);
1221 printf("%s: Bad register 0x" TARGET_FMT_plx
"\n", __func__
, addr
);
1225 static const MemoryRegionOps strongarm_uart_ops
= {
1226 .read
= strongarm_uart_read
,
1227 .write
= strongarm_uart_write
,
1228 .endianness
= DEVICE_NATIVE_ENDIAN
,
1231 static void strongarm_uart_init(Object
*obj
)
1233 StrongARMUARTState
*s
= STRONGARM_UART(obj
);
1234 SysBusDevice
*dev
= SYS_BUS_DEVICE(obj
);
1236 memory_region_init_io(&s
->iomem
, obj
, &strongarm_uart_ops
, s
,
1238 sysbus_init_mmio(dev
, &s
->iomem
);
1239 sysbus_init_irq(dev
, &s
->irq
);
1241 s
->rx_timeout_timer
= timer_new_ns(QEMU_CLOCK_VIRTUAL
, strongarm_uart_rx_to
, s
);
1242 s
->tx_timer
= timer_new_ns(QEMU_CLOCK_VIRTUAL
, strongarm_uart_tx
, s
);
1245 static void strongarm_uart_realize(DeviceState
*dev
, Error
**errp
)
1247 StrongARMUARTState
*s
= STRONGARM_UART(dev
);
1249 qemu_chr_fe_set_handlers(&s
->chr
,
1250 strongarm_uart_can_receive
,
1251 strongarm_uart_receive
,
1252 strongarm_uart_event
,
1253 NULL
, s
, NULL
, true);
1256 static void strongarm_uart_reset(DeviceState
*dev
)
1258 StrongARMUARTState
*s
= STRONGARM_UART(dev
);
1260 s
->utcr0
= UTCR0_DSS
; /* 8 data, no parity */
1261 s
->brd
= 23; /* 9600 */
1262 /* enable send & recv - this actually violates spec */
1263 s
->utcr3
= UTCR3_TXE
| UTCR3_RXE
;
1265 s
->rx_len
= s
->tx_len
= 0;
1267 strongarm_uart_update_parameters(s
);
1268 strongarm_uart_update_status(s
);
1269 strongarm_uart_update_int_status(s
);
1272 static int strongarm_uart_post_load(void *opaque
, int version_id
)
1274 StrongARMUARTState
*s
= opaque
;
1276 strongarm_uart_update_parameters(s
);
1277 strongarm_uart_update_status(s
);
1278 strongarm_uart_update_int_status(s
);
1280 /* tx and restart timer */
1282 strongarm_uart_tx(s
);
1285 /* restart rx timeout timer */
1287 timer_mod(s
->rx_timeout_timer
,
1288 qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL
) + s
->char_transmit_time
* 3);
1294 static const VMStateDescription vmstate_strongarm_uart_regs
= {
1295 .name
= "strongarm-uart",
1297 .minimum_version_id
= 0,
1298 .post_load
= strongarm_uart_post_load
,
1299 .fields
= (VMStateField
[]) {
1300 VMSTATE_UINT8(utcr0
, StrongARMUARTState
),
1301 VMSTATE_UINT16(brd
, StrongARMUARTState
),
1302 VMSTATE_UINT8(utcr3
, StrongARMUARTState
),
1303 VMSTATE_UINT8(utsr0
, StrongARMUARTState
),
1304 VMSTATE_UINT8_ARRAY(tx_fifo
, StrongARMUARTState
, 8),
1305 VMSTATE_UINT8(tx_start
, StrongARMUARTState
),
1306 VMSTATE_UINT8(tx_len
, StrongARMUARTState
),
1307 VMSTATE_UINT16_ARRAY(rx_fifo
, StrongARMUARTState
, 12),
1308 VMSTATE_UINT8(rx_start
, StrongARMUARTState
),
1309 VMSTATE_UINT8(rx_len
, StrongARMUARTState
),
1310 VMSTATE_BOOL(wait_break_end
, StrongARMUARTState
),
1311 VMSTATE_END_OF_LIST(),
1315 static Property strongarm_uart_properties
[] = {
1316 DEFINE_PROP_CHR("chardev", StrongARMUARTState
, chr
),
1317 DEFINE_PROP_END_OF_LIST(),
1320 static void strongarm_uart_class_init(ObjectClass
*klass
, void *data
)
1322 DeviceClass
*dc
= DEVICE_CLASS(klass
);
1324 dc
->desc
= "StrongARM UART controller";
1325 dc
->reset
= strongarm_uart_reset
;
1326 dc
->vmsd
= &vmstate_strongarm_uart_regs
;
1327 dc
->props
= strongarm_uart_properties
;
1328 dc
->realize
= strongarm_uart_realize
;
1331 static const TypeInfo strongarm_uart_info
= {
1332 .name
= TYPE_STRONGARM_UART
,
1333 .parent
= TYPE_SYS_BUS_DEVICE
,
1334 .instance_size
= sizeof(StrongARMUARTState
),
1335 .instance_init
= strongarm_uart_init
,
1336 .class_init
= strongarm_uart_class_init
,
1339 /* Synchronous Serial Ports */
1341 #define TYPE_STRONGARM_SSP "strongarm-ssp"
1342 #define STRONGARM_SSP(obj) \
1343 OBJECT_CHECK(StrongARMSSPState, (obj), TYPE_STRONGARM_SSP)
1345 typedef struct StrongARMSSPState
{
1346 SysBusDevice parent_obj
;
1355 uint16_t rx_fifo
[8];
1358 } StrongARMSSPState
;
1360 #define SSCR0 0x60 /* SSP Control register 0 */
1361 #define SSCR1 0x64 /* SSP Control register 1 */
1362 #define SSDR 0x6c /* SSP Data register */
1363 #define SSSR 0x74 /* SSP Status register */
1365 /* Bitfields for above registers */
1366 #define SSCR0_SPI(x) (((x) & 0x30) == 0x00)
1367 #define SSCR0_SSP(x) (((x) & 0x30) == 0x10)
1368 #define SSCR0_UWIRE(x) (((x) & 0x30) == 0x20)
1369 #define SSCR0_PSP(x) (((x) & 0x30) == 0x30)
1370 #define SSCR0_SSE (1 << 7)
1371 #define SSCR0_DSS(x) (((x) & 0xf) + 1)
1372 #define SSCR1_RIE (1 << 0)
1373 #define SSCR1_TIE (1 << 1)
1374 #define SSCR1_LBM (1 << 2)
1375 #define SSSR_TNF (1 << 2)
1376 #define SSSR_RNE (1 << 3)
1377 #define SSSR_TFS (1 << 5)
1378 #define SSSR_RFS (1 << 6)
1379 #define SSSR_ROR (1 << 7)
1380 #define SSSR_RW 0x0080
1382 static void strongarm_ssp_int_update(StrongARMSSPState
*s
)
1386 level
|= (s
->sssr
& SSSR_ROR
);
1387 level
|= (s
->sssr
& SSSR_RFS
) && (s
->sscr
[1] & SSCR1_RIE
);
1388 level
|= (s
->sssr
& SSSR_TFS
) && (s
->sscr
[1] & SSCR1_TIE
);
1389 qemu_set_irq(s
->irq
, level
);
1392 static void strongarm_ssp_fifo_update(StrongARMSSPState
*s
)
1394 s
->sssr
&= ~SSSR_TFS
;
1395 s
->sssr
&= ~SSSR_TNF
;
1396 if (s
->sscr
[0] & SSCR0_SSE
) {
1397 if (s
->rx_level
>= 4) {
1398 s
->sssr
|= SSSR_RFS
;
1400 s
->sssr
&= ~SSSR_RFS
;
1403 s
->sssr
|= SSSR_RNE
;
1405 s
->sssr
&= ~SSSR_RNE
;
1407 /* TX FIFO is never filled, so it is always in underrun
1408 condition if SSP is enabled */
1409 s
->sssr
|= SSSR_TFS
;
1410 s
->sssr
|= SSSR_TNF
;
1413 strongarm_ssp_int_update(s
);
1416 static uint64_t strongarm_ssp_read(void *opaque
, hwaddr addr
,
1419 StrongARMSSPState
*s
= opaque
;
1430 if (~s
->sscr
[0] & SSCR0_SSE
) {
1433 if (s
->rx_level
< 1) {
1434 printf("%s: SSP Rx Underrun\n", __func__
);
1438 retval
= s
->rx_fifo
[s
->rx_start
++];
1440 strongarm_ssp_fifo_update(s
);
1443 printf("%s: Bad register 0x" TARGET_FMT_plx
"\n", __func__
, addr
);
1449 static void strongarm_ssp_write(void *opaque
, hwaddr addr
,
1450 uint64_t value
, unsigned size
)
1452 StrongARMSSPState
*s
= opaque
;
1456 s
->sscr
[0] = value
& 0xffbf;
1457 if ((s
->sscr
[0] & SSCR0_SSE
) && SSCR0_DSS(value
) < 4) {
1458 printf("%s: Wrong data size: %i bits\n", __func__
,
1459 (int)SSCR0_DSS(value
));
1461 if (!(value
& SSCR0_SSE
)) {
1465 strongarm_ssp_fifo_update(s
);
1469 s
->sscr
[1] = value
& 0x2f;
1470 if (value
& SSCR1_LBM
) {
1471 printf("%s: Attempt to use SSP LBM mode\n", __func__
);
1473 strongarm_ssp_fifo_update(s
);
1477 s
->sssr
&= ~(value
& SSSR_RW
);
1478 strongarm_ssp_int_update(s
);
1482 if (SSCR0_UWIRE(s
->sscr
[0])) {
1485 /* Note how 32bits overflow does no harm here */
1486 value
&= (1 << SSCR0_DSS(s
->sscr
[0])) - 1;
1488 /* Data goes from here to the Tx FIFO and is shifted out from
1489 * there directly to the slave, no need to buffer it.
1491 if (s
->sscr
[0] & SSCR0_SSE
) {
1493 if (s
->sscr
[1] & SSCR1_LBM
) {
1496 readval
= ssi_transfer(s
->bus
, value
);
1499 if (s
->rx_level
< 0x08) {
1500 s
->rx_fifo
[(s
->rx_start
+ s
->rx_level
++) & 0x7] = readval
;
1502 s
->sssr
|= SSSR_ROR
;
1505 strongarm_ssp_fifo_update(s
);
1509 printf("%s: Bad register 0x" TARGET_FMT_plx
"\n", __func__
, addr
);
1514 static const MemoryRegionOps strongarm_ssp_ops
= {
1515 .read
= strongarm_ssp_read
,
1516 .write
= strongarm_ssp_write
,
1517 .endianness
= DEVICE_NATIVE_ENDIAN
,
1520 static int strongarm_ssp_post_load(void *opaque
, int version_id
)
1522 StrongARMSSPState
*s
= opaque
;
1524 strongarm_ssp_fifo_update(s
);
1529 static void strongarm_ssp_init(Object
*obj
)
1531 SysBusDevice
*sbd
= SYS_BUS_DEVICE(obj
);
1532 DeviceState
*dev
= DEVICE(sbd
);
1533 StrongARMSSPState
*s
= STRONGARM_SSP(dev
);
1535 sysbus_init_irq(sbd
, &s
->irq
);
1537 memory_region_init_io(&s
->iomem
, obj
, &strongarm_ssp_ops
, s
,
1539 sysbus_init_mmio(sbd
, &s
->iomem
);
1541 s
->bus
= ssi_create_bus(dev
, "ssi");
1544 static void strongarm_ssp_reset(DeviceState
*dev
)
1546 StrongARMSSPState
*s
= STRONGARM_SSP(dev
);
1548 s
->sssr
= 0x03; /* 3 bit data, SPI, disabled */
1553 static const VMStateDescription vmstate_strongarm_ssp_regs
= {
1554 .name
= "strongarm-ssp",
1556 .minimum_version_id
= 0,
1557 .post_load
= strongarm_ssp_post_load
,
1558 .fields
= (VMStateField
[]) {
1559 VMSTATE_UINT16_ARRAY(sscr
, StrongARMSSPState
, 2),
1560 VMSTATE_UINT16(sssr
, StrongARMSSPState
),
1561 VMSTATE_UINT16_ARRAY(rx_fifo
, StrongARMSSPState
, 8),
1562 VMSTATE_UINT8(rx_start
, StrongARMSSPState
),
1563 VMSTATE_UINT8(rx_level
, StrongARMSSPState
),
1564 VMSTATE_END_OF_LIST(),
1568 static void strongarm_ssp_class_init(ObjectClass
*klass
, void *data
)
1570 DeviceClass
*dc
= DEVICE_CLASS(klass
);
1572 dc
->desc
= "StrongARM SSP controller";
1573 dc
->reset
= strongarm_ssp_reset
;
1574 dc
->vmsd
= &vmstate_strongarm_ssp_regs
;
1577 static const TypeInfo strongarm_ssp_info
= {
1578 .name
= TYPE_STRONGARM_SSP
,
1579 .parent
= TYPE_SYS_BUS_DEVICE
,
1580 .instance_size
= sizeof(StrongARMSSPState
),
1581 .instance_init
= strongarm_ssp_init
,
1582 .class_init
= strongarm_ssp_class_init
,
1585 /* Main CPU functions */
1586 StrongARMState
*sa1110_init(MemoryRegion
*sysmem
,
1587 unsigned int sdram_size
, const char *cpu_type
)
1592 s
= g_new0(StrongARMState
, 1);
1594 if (strncmp(cpu_type
, "sa1110", 6)) {
1595 error_report("Machine requires a SA1110 processor.");
1599 s
->cpu
= ARM_CPU(cpu_create(cpu_type
));
1601 memory_region_allocate_system_memory(&s
->sdram
, NULL
, "strongarm.sdram",
1603 memory_region_add_subregion(sysmem
, SA_SDCS0
, &s
->sdram
);
1605 s
->pic
= sysbus_create_varargs("strongarm_pic", 0x90050000,
1606 qdev_get_gpio_in(DEVICE(s
->cpu
), ARM_CPU_IRQ
),
1607 qdev_get_gpio_in(DEVICE(s
->cpu
), ARM_CPU_FIQ
),
1610 sysbus_create_varargs("pxa25x-timer", 0x90000000,
1611 qdev_get_gpio_in(s
->pic
, SA_PIC_OSTC0
),
1612 qdev_get_gpio_in(s
->pic
, SA_PIC_OSTC1
),
1613 qdev_get_gpio_in(s
->pic
, SA_PIC_OSTC2
),
1614 qdev_get_gpio_in(s
->pic
, SA_PIC_OSTC3
),
1617 sysbus_create_simple(TYPE_STRONGARM_RTC
, 0x90010000,
1618 qdev_get_gpio_in(s
->pic
, SA_PIC_RTC_ALARM
));
1620 s
->gpio
= strongarm_gpio_init(0x90040000, s
->pic
);
1622 s
->ppc
= sysbus_create_varargs(TYPE_STRONGARM_PPC
, 0x90060000, NULL
);
1624 for (i
= 0; sa_serial
[i
].io_base
; i
++) {
1625 DeviceState
*dev
= qdev_create(NULL
, TYPE_STRONGARM_UART
);
1626 qdev_prop_set_chr(dev
, "chardev", serial_hd(i
));
1627 qdev_init_nofail(dev
);
1628 sysbus_mmio_map(SYS_BUS_DEVICE(dev
), 0,
1629 sa_serial
[i
].io_base
);
1630 sysbus_connect_irq(SYS_BUS_DEVICE(dev
), 0,
1631 qdev_get_gpio_in(s
->pic
, sa_serial
[i
].irq
));
1634 s
->ssp
= sysbus_create_varargs(TYPE_STRONGARM_SSP
, 0x80070000,
1635 qdev_get_gpio_in(s
->pic
, SA_PIC_SSP
), NULL
);
1636 s
->ssp_bus
= (SSIBus
*)qdev_get_child_bus(s
->ssp
, "ssi");
1641 static void strongarm_register_types(void)
1643 type_register_static(&strongarm_pic_info
);
1644 type_register_static(&strongarm_rtc_sysbus_info
);
1645 type_register_static(&strongarm_gpio_info
);
1646 type_register_static(&strongarm_ppc_info
);
1647 type_register_static(&strongarm_uart_info
);
1648 type_register_static(&strongarm_ssp_info
);
1651 type_init(strongarm_register_types
)