2 * PXA270-based Clamshell PDA platforms.
4 * Copyright (c) 2006 Openedhand Ltd.
5 * Written by Andrzej Zaborowski <balrog@zabor.org>
7 * This code is licensed under the GNU GPL v2.
9 * Contributions after 2012-01-13 are licensed under the terms of the
10 * GNU GPL, version 2 or (at your option) any later version.
13 #include "qemu/osdep.h"
14 #include "qapi/error.h"
15 #include "hw/arm/pxa.h"
16 #include "hw/arm/boot.h"
17 #include "sysemu/runstate.h"
18 #include "sysemu/sysemu.h"
19 #include "hw/pcmcia.h"
20 #include "hw/qdev-properties.h"
21 #include "hw/i2c/i2c.h"
23 #include "hw/ssi/ssi.h"
24 #include "hw/block/flash.h"
25 #include "qemu/timer.h"
27 #include "hw/arm/sharpsl.h"
28 #include "ui/console.h"
29 #include "hw/audio/wm8750.h"
30 #include "audio/audio.h"
31 #include "hw/boards.h"
32 #include "hw/sysbus.h"
33 #include "hw/adc/max111x.h"
34 #include "migration/vmstate.h"
35 #include "exec/address-spaces.h"
37 #include "qom/object.h"
38 #include "audio/audio.h"
40 enum spitz_model_e
{ spitz
, akita
, borzoi
, terrier
};
42 struct SpitzMachineClass
{
44 enum spitz_model_e model
;
48 struct SpitzMachineState
{
57 DeviceState
*misc_gpio
;
60 #define TYPE_SPITZ_MACHINE "spitz-common"
61 OBJECT_DECLARE_TYPE(SpitzMachineState
, SpitzMachineClass
, SPITZ_MACHINE
)
63 #define zaurus_printf(format, ...) \
64 fprintf(stderr, "%s: " format, __func__, ##__VA_ARGS__)
67 #define FLASH_BASE 0x0c000000
68 #define FLASH_ECCLPLB 0x00 /* Line parity 7 - 0 bit */
69 #define FLASH_ECCLPUB 0x04 /* Line parity 15 - 8 bit */
70 #define FLASH_ECCCP 0x08 /* Column parity 5 - 0 bit */
71 #define FLASH_ECCCNTR 0x0c /* ECC byte counter */
72 #define FLASH_ECCCLRR 0x10 /* Clear ECC */
73 #define FLASH_FLASHIO 0x14 /* Flash I/O */
74 #define FLASH_FLASHCTL 0x18 /* Flash Control */
76 #define FLASHCTL_CE0 (1 << 0)
77 #define FLASHCTL_CLE (1 << 1)
78 #define FLASHCTL_ALE (1 << 2)
79 #define FLASHCTL_WP (1 << 3)
80 #define FLASHCTL_CE1 (1 << 4)
81 #define FLASHCTL_RYBY (1 << 5)
82 #define FLASHCTL_NCE (FLASHCTL_CE0 | FLASHCTL_CE1)
84 #define TYPE_SL_NAND "sl-nand"
85 OBJECT_DECLARE_SIMPLE_TYPE(SLNANDState
, SL_NAND
)
88 SysBusDevice parent_obj
;
98 static uint64_t sl_read(void *opaque
, hwaddr addr
, unsigned size
)
100 SLNANDState
*s
= (SLNANDState
*) opaque
;
104 #define BSHR(byte, from, to) ((s->ecc.lp[byte] >> (from - to)) & (1 << to))
106 return BSHR(0, 4, 0) | BSHR(0, 5, 2) | BSHR(0, 6, 4) | BSHR(0, 7, 6) |
107 BSHR(1, 4, 1) | BSHR(1, 5, 3) | BSHR(1, 6, 5) | BSHR(1, 7, 7);
109 #define BSHL(byte, from, to) ((s->ecc.lp[byte] << (to - from)) & (1 << to))
111 return BSHL(0, 0, 0) | BSHL(0, 1, 2) | BSHL(0, 2, 4) | BSHL(0, 3, 6) |
112 BSHL(1, 0, 1) | BSHL(1, 1, 3) | BSHL(1, 2, 5) | BSHL(1, 3, 7);
118 return s
->ecc
.count
& 0xff;
121 nand_getpins(s
->nand
, &ryby
);
123 return s
->ctl
| FLASHCTL_RYBY
;
129 return ecc_digest(&s
->ecc
, nand_getio(s
->nand
)) |
130 (ecc_digest(&s
->ecc
, nand_getio(s
->nand
)) << 16);
132 return ecc_digest(&s
->ecc
, nand_getio(s
->nand
));
135 qemu_log_mask(LOG_GUEST_ERROR
,
136 "sl_read: bad register offset 0x%02" HWADDR_PRIx
"\n",
142 static void sl_write(void *opaque
, hwaddr addr
,
143 uint64_t value
, unsigned size
)
145 SLNANDState
*s
= (SLNANDState
*) opaque
;
149 /* Value is ignored. */
154 s
->ctl
= value
& 0xff & ~FLASHCTL_RYBY
;
155 nand_setpins(s
->nand
,
156 s
->ctl
& FLASHCTL_CLE
,
157 s
->ctl
& FLASHCTL_ALE
,
158 s
->ctl
& FLASHCTL_NCE
,
159 s
->ctl
& FLASHCTL_WP
,
164 nand_setio(s
->nand
, ecc_digest(&s
->ecc
, value
& 0xff));
168 qemu_log_mask(LOG_GUEST_ERROR
,
169 "sl_write: bad register offset 0x%02" HWADDR_PRIx
"\n",
179 static const MemoryRegionOps sl_ops
= {
182 .endianness
= DEVICE_NATIVE_ENDIAN
,
185 static void sl_flash_register(PXA2xxState
*cpu
, int size
)
189 dev
= qdev_new(TYPE_SL_NAND
);
191 qdev_prop_set_uint8(dev
, "manf_id", NAND_MFR_SAMSUNG
);
192 if (size
== FLASH_128M
)
193 qdev_prop_set_uint8(dev
, "chip_id", 0x73);
194 else if (size
== FLASH_1024M
)
195 qdev_prop_set_uint8(dev
, "chip_id", 0xf1);
197 sysbus_realize_and_unref(SYS_BUS_DEVICE(dev
), &error_fatal
);
198 sysbus_mmio_map(SYS_BUS_DEVICE(dev
), 0, FLASH_BASE
);
201 static void sl_nand_init(Object
*obj
)
203 SLNANDState
*s
= SL_NAND(obj
);
204 SysBusDevice
*dev
= SYS_BUS_DEVICE(obj
);
208 memory_region_init_io(&s
->iomem
, obj
, &sl_ops
, s
, "sl", 0x40);
209 sysbus_init_mmio(dev
, &s
->iomem
);
212 static void sl_nand_realize(DeviceState
*dev
, Error
**errp
)
214 SLNANDState
*s
= SL_NAND(dev
);
217 /* FIXME use a qdev drive property instead of drive_get() */
218 nand
= drive_get(IF_MTD
, 0, 0);
219 s
->nand
= nand_init(nand
? blk_by_legacy_dinfo(nand
) : NULL
,
220 s
->manf_id
, s
->chip_id
);
225 #define SPITZ_KEY_STROBE_NUM 11
226 #define SPITZ_KEY_SENSE_NUM 7
228 static const int spitz_gpio_key_sense
[SPITZ_KEY_SENSE_NUM
] = {
229 12, 17, 91, 34, 36, 38, 39
232 static const int spitz_gpio_key_strobe
[SPITZ_KEY_STROBE_NUM
] = {
233 88, 23, 24, 25, 26, 27, 52, 103, 107, 108, 114
236 /* Eighth additional row maps the special keys */
237 static int spitz_keymap
[SPITZ_KEY_SENSE_NUM
+ 1][SPITZ_KEY_STROBE_NUM
] = {
238 { 0x1d, 0x02, 0x04, 0x06, 0x07, 0x08, 0x0a, 0x0b, 0x0e, 0x3f, 0x40 },
239 { -1 , 0x03, 0x05, 0x13, 0x15, 0x09, 0x17, 0x18, 0x19, 0x41, 0x42 },
240 { 0x0f, 0x10, 0x12, 0x14, 0x22, 0x16, 0x24, 0x25, -1 , -1 , -1 },
241 { 0x3c, 0x11, 0x1f, 0x21, 0x2f, 0x23, 0x32, 0x26, -1 , 0x36, -1 },
242 { 0x3b, 0x1e, 0x20, 0x2e, 0x30, 0x31, 0x34, -1 , 0x1c, 0x2a, -1 },
243 { 0x44, 0x2c, 0x2d, 0x0c, 0x39, 0x33, -1 , 0x48, -1 , -1 , 0x38 },
244 { 0x37, 0x3d, -1 , 0x45, 0x57, 0x58, 0x4b, 0x50, 0x4d, -1 , -1 },
245 { 0x52, 0x43, 0x01, 0x47, 0x49, -1 , -1 , -1 , -1 , -1 , -1 },
248 #define SPITZ_GPIO_AK_INT 13 /* Remote control */
249 #define SPITZ_GPIO_SYNC 16 /* Sync button */
250 #define SPITZ_GPIO_ON_KEY 95 /* Power button */
251 #define SPITZ_GPIO_SWA 97 /* Lid */
252 #define SPITZ_GPIO_SWB 96 /* Tablet mode */
254 /* The special buttons are mapped to unused keys */
255 static const int spitz_gpiomap
[5] = {
256 SPITZ_GPIO_AK_INT
, SPITZ_GPIO_SYNC
, SPITZ_GPIO_ON_KEY
,
257 SPITZ_GPIO_SWA
, SPITZ_GPIO_SWB
,
260 #define TYPE_SPITZ_KEYBOARD "spitz-keyboard"
261 OBJECT_DECLARE_SIMPLE_TYPE(SpitzKeyboardState
, SPITZ_KEYBOARD
)
263 struct SpitzKeyboardState
{
264 SysBusDevice parent_obj
;
266 qemu_irq sense
[SPITZ_KEY_SENSE_NUM
];
269 uint16_t keyrow
[SPITZ_KEY_SENSE_NUM
];
270 uint16_t strobe_state
;
271 uint16_t sense_state
;
273 uint16_t pre_map
[0x100];
277 int fifopos
, fifolen
;
281 static void spitz_keyboard_sense_update(SpitzKeyboardState
*s
)
284 uint16_t strobe
, sense
= 0;
285 for (i
= 0; i
< SPITZ_KEY_SENSE_NUM
; i
++) {
286 strobe
= s
->keyrow
[i
] & s
->strobe_state
;
289 if (!(s
->sense_state
& (1 << i
)))
290 qemu_irq_raise(s
->sense
[i
]);
291 } else if (s
->sense_state
& (1 << i
))
292 qemu_irq_lower(s
->sense
[i
]);
295 s
->sense_state
= sense
;
298 static void spitz_keyboard_strobe(void *opaque
, int line
, int level
)
300 SpitzKeyboardState
*s
= (SpitzKeyboardState
*) opaque
;
303 s
->strobe_state
|= 1 << line
;
305 s
->strobe_state
&= ~(1 << line
);
306 spitz_keyboard_sense_update(s
);
309 static void spitz_keyboard_keydown(SpitzKeyboardState
*s
, int keycode
)
311 int spitz_keycode
= s
->keymap
[keycode
& 0x7f];
312 if (spitz_keycode
== -1)
315 /* Handle the additional keys */
316 if ((spitz_keycode
>> 4) == SPITZ_KEY_SENSE_NUM
) {
317 qemu_set_irq(s
->gpiomap
[spitz_keycode
& 0xf], (keycode
< 0x80));
322 s
->keyrow
[spitz_keycode
>> 4] &= ~(1 << (spitz_keycode
& 0xf));
324 s
->keyrow
[spitz_keycode
>> 4] |= 1 << (spitz_keycode
& 0xf);
326 spitz_keyboard_sense_update(s
);
329 #define SPITZ_MOD_SHIFT (1 << 7)
330 #define SPITZ_MOD_CTRL (1 << 8)
331 #define SPITZ_MOD_FN (1 << 9)
333 #define QUEUE_KEY(c) s->fifo[(s->fifopos + s->fifolen ++) & 0xf] = c
335 static void spitz_keyboard_handler(void *opaque
, int keycode
)
337 SpitzKeyboardState
*s
= opaque
;
341 case 0x2a: /* Left Shift */
347 case 0x36: /* Right Shift */
353 case 0x1d: /* Control */
367 code
= s
->pre_map
[mapcode
= ((s
->modifiers
& 3) ?
368 (keycode
| SPITZ_MOD_SHIFT
) :
369 (keycode
& ~SPITZ_MOD_SHIFT
))];
371 if (code
!= mapcode
) {
373 if ((code
& SPITZ_MOD_SHIFT
) && !(s
->modifiers
& 1)) {
374 QUEUE_KEY(0x2a | (keycode
& 0x80));
376 if ((code
& SPITZ_MOD_CTRL
) && !(s
->modifiers
& 4)) {
377 QUEUE_KEY(0x1d | (keycode
& 0x80));
379 if ((code
& SPITZ_MOD_FN
) && !(s
->modifiers
& 8)) {
380 QUEUE_KEY(0x38 | (keycode
& 0x80));
382 if ((code
& SPITZ_MOD_FN
) && (s
->modifiers
& 1)) {
383 QUEUE_KEY(0x2a | (~keycode
& 0x80));
385 if ((code
& SPITZ_MOD_FN
) && (s
->modifiers
& 2)) {
386 QUEUE_KEY(0x36 | (~keycode
& 0x80));
389 if (keycode
& 0x80) {
390 if ((s
->imodifiers
& 1 ) && !(s
->modifiers
& 1))
391 QUEUE_KEY(0x2a | 0x80);
392 if ((s
->imodifiers
& 4 ) && !(s
->modifiers
& 4))
393 QUEUE_KEY(0x1d | 0x80);
394 if ((s
->imodifiers
& 8 ) && !(s
->modifiers
& 8))
395 QUEUE_KEY(0x38 | 0x80);
396 if ((s
->imodifiers
& 0x10) && (s
->modifiers
& 1))
398 if ((s
->imodifiers
& 0x20) && (s
->modifiers
& 2))
402 if ((code
& SPITZ_MOD_SHIFT
) &&
403 !((s
->modifiers
| s
->imodifiers
) & 1)) {
407 if ((code
& SPITZ_MOD_CTRL
) &&
408 !((s
->modifiers
| s
->imodifiers
) & 4)) {
412 if ((code
& SPITZ_MOD_FN
) &&
413 !((s
->modifiers
| s
->imodifiers
) & 8)) {
417 if ((code
& SPITZ_MOD_FN
) && (s
->modifiers
& 1) &&
418 !(s
->imodifiers
& 0x10)) {
419 QUEUE_KEY(0x2a | 0x80);
420 s
->imodifiers
|= 0x10;
422 if ((code
& SPITZ_MOD_FN
) && (s
->modifiers
& 2) &&
423 !(s
->imodifiers
& 0x20)) {
424 QUEUE_KEY(0x36 | 0x80);
425 s
->imodifiers
|= 0x20;
431 QUEUE_KEY((code
& 0x7f) | (keycode
& 0x80));
434 static void spitz_keyboard_tick(void *opaque
)
436 SpitzKeyboardState
*s
= (SpitzKeyboardState
*) opaque
;
439 spitz_keyboard_keydown(s
, s
->fifo
[s
->fifopos
++]);
441 if (s
->fifopos
>= 16)
445 timer_mod(s
->kbdtimer
, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL
) +
446 NANOSECONDS_PER_SECOND
/ 32);
449 static void spitz_keyboard_pre_map(SpitzKeyboardState
*s
)
452 for (i
= 0; i
< 0x100; i
++)
454 s
->pre_map
[0x02 | SPITZ_MOD_SHIFT
] = 0x02 | SPITZ_MOD_SHIFT
; /* exclam */
455 s
->pre_map
[0x28 | SPITZ_MOD_SHIFT
] = 0x03 | SPITZ_MOD_SHIFT
; /* quotedbl */
456 s
->pre_map
[0x04 | SPITZ_MOD_SHIFT
] = 0x04 | SPITZ_MOD_SHIFT
; /* # */
457 s
->pre_map
[0x05 | SPITZ_MOD_SHIFT
] = 0x05 | SPITZ_MOD_SHIFT
; /* dollar */
458 s
->pre_map
[0x06 | SPITZ_MOD_SHIFT
] = 0x06 | SPITZ_MOD_SHIFT
; /* percent */
459 s
->pre_map
[0x08 | SPITZ_MOD_SHIFT
] = 0x07 | SPITZ_MOD_SHIFT
; /* ampersand */
460 s
->pre_map
[0x28] = 0x08 | SPITZ_MOD_SHIFT
; /* ' */
461 s
->pre_map
[0x0a | SPITZ_MOD_SHIFT
] = 0x09 | SPITZ_MOD_SHIFT
; /* ( */
462 s
->pre_map
[0x0b | SPITZ_MOD_SHIFT
] = 0x0a | SPITZ_MOD_SHIFT
; /* ) */
463 s
->pre_map
[0x29 | SPITZ_MOD_SHIFT
] = 0x0b | SPITZ_MOD_SHIFT
; /* tilde */
464 s
->pre_map
[0x03 | SPITZ_MOD_SHIFT
] = 0x0c | SPITZ_MOD_SHIFT
; /* at */
465 s
->pre_map
[0xd3] = 0x0e | SPITZ_MOD_FN
; /* Delete */
466 s
->pre_map
[0x3a] = 0x0f | SPITZ_MOD_FN
; /* Caps_Lock */
467 s
->pre_map
[0x07 | SPITZ_MOD_SHIFT
] = 0x11 | SPITZ_MOD_FN
; /* ^ */
468 s
->pre_map
[0x0d] = 0x12 | SPITZ_MOD_FN
; /* equal */
469 s
->pre_map
[0x0d | SPITZ_MOD_SHIFT
] = 0x13 | SPITZ_MOD_FN
; /* plus */
470 s
->pre_map
[0x1a] = 0x14 | SPITZ_MOD_FN
; /* [ */
471 s
->pre_map
[0x1b] = 0x15 | SPITZ_MOD_FN
; /* ] */
472 s
->pre_map
[0x1a | SPITZ_MOD_SHIFT
] = 0x16 | SPITZ_MOD_FN
; /* { */
473 s
->pre_map
[0x1b | SPITZ_MOD_SHIFT
] = 0x17 | SPITZ_MOD_FN
; /* } */
474 s
->pre_map
[0x27] = 0x22 | SPITZ_MOD_FN
; /* semicolon */
475 s
->pre_map
[0x27 | SPITZ_MOD_SHIFT
] = 0x23 | SPITZ_MOD_FN
; /* colon */
476 s
->pre_map
[0x09 | SPITZ_MOD_SHIFT
] = 0x24 | SPITZ_MOD_FN
; /* asterisk */
477 s
->pre_map
[0x2b] = 0x25 | SPITZ_MOD_FN
; /* backslash */
478 s
->pre_map
[0x2b | SPITZ_MOD_SHIFT
] = 0x26 | SPITZ_MOD_FN
; /* bar */
479 s
->pre_map
[0x0c | SPITZ_MOD_SHIFT
] = 0x30 | SPITZ_MOD_FN
; /* _ */
480 s
->pre_map
[0x33 | SPITZ_MOD_SHIFT
] = 0x33 | SPITZ_MOD_FN
; /* less */
481 s
->pre_map
[0x35] = 0x33 | SPITZ_MOD_SHIFT
; /* slash */
482 s
->pre_map
[0x34 | SPITZ_MOD_SHIFT
] = 0x34 | SPITZ_MOD_FN
; /* greater */
483 s
->pre_map
[0x35 | SPITZ_MOD_SHIFT
] = 0x34 | SPITZ_MOD_SHIFT
; /* question */
484 s
->pre_map
[0x49] = 0x48 | SPITZ_MOD_FN
; /* Page_Up */
485 s
->pre_map
[0x51] = 0x50 | SPITZ_MOD_FN
; /* Page_Down */
493 #undef SPITZ_MOD_SHIFT
494 #undef SPITZ_MOD_CTRL
497 static int spitz_keyboard_post_load(void *opaque
, int version_id
)
499 SpitzKeyboardState
*s
= (SpitzKeyboardState
*) opaque
;
501 /* Release all pressed keys */
502 memset(s
->keyrow
, 0, sizeof(s
->keyrow
));
503 spitz_keyboard_sense_update(s
);
512 static void spitz_keyboard_register(PXA2xxState
*cpu
)
516 SpitzKeyboardState
*s
;
518 dev
= sysbus_create_simple(TYPE_SPITZ_KEYBOARD
, -1, NULL
);
519 s
= SPITZ_KEYBOARD(dev
);
521 for (i
= 0; i
< SPITZ_KEY_SENSE_NUM
; i
++)
522 qdev_connect_gpio_out(dev
, i
, qdev_get_gpio_in(cpu
->gpio
, spitz_gpio_key_sense
[i
]));
524 for (i
= 0; i
< 5; i
++)
525 s
->gpiomap
[i
] = qdev_get_gpio_in(cpu
->gpio
, spitz_gpiomap
[i
]);
528 s
->gpiomap
[4] = qemu_irq_invert(s
->gpiomap
[4]);
530 for (i
= 0; i
< 5; i
++)
531 qemu_set_irq(s
->gpiomap
[i
], 0);
533 for (i
= 0; i
< SPITZ_KEY_STROBE_NUM
; i
++)
534 qdev_connect_gpio_out(cpu
->gpio
, spitz_gpio_key_strobe
[i
],
535 qdev_get_gpio_in(dev
, i
));
537 timer_mod(s
->kbdtimer
, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL
));
539 qemu_add_kbd_event_handler(spitz_keyboard_handler
, s
);
542 static void spitz_keyboard_init(Object
*obj
)
544 DeviceState
*dev
= DEVICE(obj
);
545 SpitzKeyboardState
*s
= SPITZ_KEYBOARD(obj
);
548 for (i
= 0; i
< 0x80; i
++)
550 for (i
= 0; i
< SPITZ_KEY_SENSE_NUM
+ 1; i
++)
551 for (j
= 0; j
< SPITZ_KEY_STROBE_NUM
; j
++)
552 if (spitz_keymap
[i
][j
] != -1)
553 s
->keymap
[spitz_keymap
[i
][j
]] = (i
<< 4) | j
;
555 spitz_keyboard_pre_map(s
);
557 qdev_init_gpio_in(dev
, spitz_keyboard_strobe
, SPITZ_KEY_STROBE_NUM
);
558 qdev_init_gpio_out(dev
, s
->sense
, SPITZ_KEY_SENSE_NUM
);
561 static void spitz_keyboard_realize(DeviceState
*dev
, Error
**errp
)
563 SpitzKeyboardState
*s
= SPITZ_KEYBOARD(dev
);
564 s
->kbdtimer
= timer_new_ns(QEMU_CLOCK_VIRTUAL
, spitz_keyboard_tick
, s
);
567 /* LCD backlight controller */
569 #define LCDTG_RESCTL 0x00
570 #define LCDTG_PHACTRL 0x01
571 #define LCDTG_DUTYCTRL 0x02
572 #define LCDTG_POWERREG0 0x03
573 #define LCDTG_POWERREG1 0x04
574 #define LCDTG_GPOR3 0x05
575 #define LCDTG_PICTRL 0x06
576 #define LCDTG_POLCTRL 0x07
578 #define TYPE_SPITZ_LCDTG "spitz-lcdtg"
579 OBJECT_DECLARE_SIMPLE_TYPE(SpitzLCDTG
, SPITZ_LCDTG
)
582 SSIPeripheral ssidev
;
583 uint32_t bl_intensity
;
587 static void spitz_bl_update(SpitzLCDTG
*s
)
589 if (s
->bl_power
&& s
->bl_intensity
)
590 zaurus_printf("LCD Backlight now at %u/63\n", s
->bl_intensity
);
592 zaurus_printf("LCD Backlight now off\n");
595 static inline void spitz_bl_bit5(void *opaque
, int line
, int level
)
597 SpitzLCDTG
*s
= opaque
;
598 int prev
= s
->bl_intensity
;
601 s
->bl_intensity
&= ~0x20;
603 s
->bl_intensity
|= 0x20;
605 if (s
->bl_power
&& prev
!= s
->bl_intensity
)
609 static inline void spitz_bl_power(void *opaque
, int line
, int level
)
611 SpitzLCDTG
*s
= opaque
;
612 s
->bl_power
= !!level
;
616 static uint32_t spitz_lcdtg_transfer(SSIPeripheral
*dev
, uint32_t value
)
618 SpitzLCDTG
*s
= SPITZ_LCDTG(dev
);
626 zaurus_printf("LCD in QVGA mode\n");
628 zaurus_printf("LCD in VGA mode\n");
632 s
->bl_intensity
&= ~0x1f;
633 s
->bl_intensity
|= value
;
638 case LCDTG_POWERREG0
:
639 /* Set common voltage to M62332FP */
645 static void spitz_lcdtg_realize(SSIPeripheral
*ssi
, Error
**errp
)
647 SpitzLCDTG
*s
= SPITZ_LCDTG(ssi
);
648 DeviceState
*dev
= DEVICE(s
);
651 s
->bl_intensity
= 0x20;
653 qdev_init_gpio_in_named(dev
, spitz_bl_bit5
, "bl_bit5", 1);
654 qdev_init_gpio_in_named(dev
, spitz_bl_power
, "bl_power", 1);
659 #define CORGI_SSP_PORT 2
661 #define SPITZ_GPIO_LCDCON_CS 53
662 #define SPITZ_GPIO_ADS7846_CS 14
663 #define SPITZ_GPIO_MAX1111_CS 20
664 #define SPITZ_GPIO_TP_INT 11
666 #define TYPE_CORGI_SSP "corgi-ssp"
667 OBJECT_DECLARE_SIMPLE_TYPE(CorgiSSPState
, CORGI_SSP
)
669 /* "Demux" the signal based on current chipselect */
670 struct CorgiSSPState
{
671 SSIPeripheral ssidev
;
676 static uint32_t corgi_ssp_transfer(SSIPeripheral
*dev
, uint32_t value
)
678 CorgiSSPState
*s
= CORGI_SSP(dev
);
681 for (i
= 0; i
< 3; i
++) {
683 return ssi_transfer(s
->bus
[i
], value
);
689 static void corgi_ssp_gpio_cs(void *opaque
, int line
, int level
)
691 CorgiSSPState
*s
= (CorgiSSPState
*)opaque
;
692 assert(line
>= 0 && line
< 3);
693 s
->enable
[line
] = !level
;
696 #define MAX1111_BATT_VOLT 1
697 #define MAX1111_BATT_TEMP 2
698 #define MAX1111_ACIN_VOLT 3
700 #define SPITZ_BATTERY_TEMP 0xe0 /* About 2.9V */
701 #define SPITZ_BATTERY_VOLT 0xd0 /* About 4.0V */
702 #define SPITZ_CHARGEON_ACIN 0x80 /* About 5.0V */
704 static void corgi_ssp_realize(SSIPeripheral
*d
, Error
**errp
)
706 DeviceState
*dev
= DEVICE(d
);
707 CorgiSSPState
*s
= CORGI_SSP(d
);
709 qdev_init_gpio_in(dev
, corgi_ssp_gpio_cs
, 3);
710 s
->bus
[0] = ssi_create_bus(dev
, "ssi0");
711 s
->bus
[1] = ssi_create_bus(dev
, "ssi1");
712 s
->bus
[2] = ssi_create_bus(dev
, "ssi2");
715 static void spitz_ssp_attach(SpitzMachineState
*sms
)
719 sms
->mux
= ssi_create_peripheral(sms
->mpu
->ssp
[CORGI_SSP_PORT
- 1],
722 bus
= qdev_get_child_bus(sms
->mux
, "ssi0");
723 sms
->lcdtg
= ssi_create_peripheral(bus
, TYPE_SPITZ_LCDTG
);
725 bus
= qdev_get_child_bus(sms
->mux
, "ssi1");
726 sms
->ads7846
= ssi_create_peripheral(bus
, "ads7846");
727 qdev_connect_gpio_out(sms
->ads7846
, 0,
728 qdev_get_gpio_in(sms
->mpu
->gpio
, SPITZ_GPIO_TP_INT
));
730 bus
= qdev_get_child_bus(sms
->mux
, "ssi2");
731 sms
->max1111
= qdev_new(TYPE_MAX_1111
);
732 qdev_prop_set_uint8(sms
->max1111
, "input1" /* BATT_VOLT */,
734 qdev_prop_set_uint8(sms
->max1111
, "input2" /* BATT_TEMP */, 0);
735 qdev_prop_set_uint8(sms
->max1111
, "input3" /* ACIN_VOLT */,
736 SPITZ_CHARGEON_ACIN
);
737 ssi_realize_and_unref(sms
->max1111
, bus
, &error_fatal
);
739 qdev_connect_gpio_out(sms
->mpu
->gpio
, SPITZ_GPIO_LCDCON_CS
,
740 qdev_get_gpio_in(sms
->mux
, 0));
741 qdev_connect_gpio_out(sms
->mpu
->gpio
, SPITZ_GPIO_ADS7846_CS
,
742 qdev_get_gpio_in(sms
->mux
, 1));
743 qdev_connect_gpio_out(sms
->mpu
->gpio
, SPITZ_GPIO_MAX1111_CS
,
744 qdev_get_gpio_in(sms
->mux
, 2));
749 static void spitz_microdrive_attach(PXA2xxState
*cpu
, int slot
)
754 dinfo
= drive_get(IF_IDE
, 0, 0);
755 if (!dinfo
|| dinfo
->media_cd
)
757 md
= dscm1xxxx_init(dinfo
);
758 pxa2xx_pcmcia_attach(cpu
->pcmcia
[slot
], md
);
761 /* Wm8750 and Max7310 on I2C */
763 #define AKITA_MAX_ADDR 0x18
764 #define SPITZ_WM_ADDRL 0x1b
765 #define SPITZ_WM_ADDRH 0x1a
767 #define SPITZ_GPIO_WM 5
769 static void spitz_wm8750_addr(void *opaque
, int line
, int level
)
771 I2CSlave
*wm
= (I2CSlave
*) opaque
;
773 i2c_slave_set_address(wm
, SPITZ_WM_ADDRH
);
775 i2c_slave_set_address(wm
, SPITZ_WM_ADDRL
);
778 static void spitz_i2c_setup(MachineState
*machine
, PXA2xxState
*cpu
)
780 /* Attach the CPU on one end of our I2C bus. */
781 I2CBus
*bus
= pxa2xx_i2c_bus(cpu
->i2c
[0]);
783 /* Attach a WM8750 to the bus */
784 I2CSlave
*i2c_dev
= i2c_slave_new(TYPE_WM8750
, 0);
785 DeviceState
*wm
= DEVICE(i2c_dev
);
787 if (machine
->audiodev
) {
788 qdev_prop_set_string(wm
, "audiodev", machine
->audiodev
);
790 i2c_slave_realize_and_unref(i2c_dev
, bus
, &error_abort
);
792 spitz_wm8750_addr(wm
, 0, 0);
793 qdev_connect_gpio_out(cpu
->gpio
, SPITZ_GPIO_WM
,
794 qemu_allocate_irq(spitz_wm8750_addr
, wm
, 0));
795 /* .. and to the sound interface. */
796 cpu
->i2s
->opaque
= wm
;
797 cpu
->i2s
->codec_out
= wm8750_dac_dat
;
798 cpu
->i2s
->codec_in
= wm8750_adc_dat
;
799 wm8750_data_req_set(wm
, cpu
->i2s
->data_req
, cpu
->i2s
);
802 static void spitz_akita_i2c_setup(PXA2xxState
*cpu
)
804 /* Attach a Max7310 to Akita I2C bus. */
805 i2c_slave_create_simple(pxa2xx_i2c_bus(cpu
->i2c
[0]), "max7310",
809 /* Other peripherals */
812 * Encapsulation of some miscellaneous GPIO line behaviour for the Spitz boards.
815 * + named GPIO inputs "green-led", "orange-led", "charging", "discharging":
816 * these currently just print messages that the line has been signalled
817 * + named GPIO input "adc-temp-on": set to cause the battery-temperature
818 * value to be passed to the max111x ADC
819 * + named GPIO output "adc-temp": the ADC value, to be wired up to the max111x
821 #define TYPE_SPITZ_MISC_GPIO "spitz-misc-gpio"
822 OBJECT_DECLARE_SIMPLE_TYPE(SpitzMiscGPIOState
, SPITZ_MISC_GPIO
)
824 struct SpitzMiscGPIOState
{
825 SysBusDevice parent_obj
;
830 static void spitz_misc_charging(void *opaque
, int n
, int level
)
832 zaurus_printf("Charging %s.\n", level
? "off" : "on");
835 static void spitz_misc_discharging(void *opaque
, int n
, int level
)
837 zaurus_printf("Discharging %s.\n", level
? "off" : "on");
840 static void spitz_misc_green_led(void *opaque
, int n
, int level
)
842 zaurus_printf("Green LED %s.\n", level
? "off" : "on");
845 static void spitz_misc_orange_led(void *opaque
, int n
, int level
)
847 zaurus_printf("Orange LED %s.\n", level
? "off" : "on");
850 static void spitz_misc_adc_temp(void *opaque
, int n
, int level
)
852 SpitzMiscGPIOState
*s
= SPITZ_MISC_GPIO(opaque
);
853 int batt_temp
= level
? SPITZ_BATTERY_TEMP
: 0;
855 qemu_set_irq(s
->adc_value
, batt_temp
);
858 static void spitz_misc_gpio_init(Object
*obj
)
860 SpitzMiscGPIOState
*s
= SPITZ_MISC_GPIO(obj
);
861 DeviceState
*dev
= DEVICE(obj
);
863 qdev_init_gpio_in_named(dev
, spitz_misc_charging
, "charging", 1);
864 qdev_init_gpio_in_named(dev
, spitz_misc_discharging
, "discharging", 1);
865 qdev_init_gpio_in_named(dev
, spitz_misc_green_led
, "green-led", 1);
866 qdev_init_gpio_in_named(dev
, spitz_misc_orange_led
, "orange-led", 1);
867 qdev_init_gpio_in_named(dev
, spitz_misc_adc_temp
, "adc-temp-on", 1);
869 qdev_init_gpio_out_named(dev
, &s
->adc_value
, "adc-temp", 1);
872 #define SPITZ_SCP_LED_GREEN 1
873 #define SPITZ_SCP_JK_B 2
874 #define SPITZ_SCP_CHRG_ON 3
875 #define SPITZ_SCP_MUTE_L 4
876 #define SPITZ_SCP_MUTE_R 5
877 #define SPITZ_SCP_CF_POWER 6
878 #define SPITZ_SCP_LED_ORANGE 7
879 #define SPITZ_SCP_JK_A 8
880 #define SPITZ_SCP_ADC_TEMP_ON 9
881 #define SPITZ_SCP2_IR_ON 1
882 #define SPITZ_SCP2_AKIN_PULLUP 2
883 #define SPITZ_SCP2_BACKLIGHT_CONT 7
884 #define SPITZ_SCP2_BACKLIGHT_ON 8
885 #define SPITZ_SCP2_MIC_BIAS 9
887 static void spitz_scoop_gpio_setup(SpitzMachineState
*sms
)
889 DeviceState
*miscdev
= sysbus_create_simple(TYPE_SPITZ_MISC_GPIO
, -1, NULL
);
891 sms
->misc_gpio
= miscdev
;
893 qdev_connect_gpio_out(sms
->scp0
, SPITZ_SCP_CHRG_ON
,
894 qdev_get_gpio_in_named(miscdev
, "charging", 0));
895 qdev_connect_gpio_out(sms
->scp0
, SPITZ_SCP_JK_B
,
896 qdev_get_gpio_in_named(miscdev
, "discharging", 0));
897 qdev_connect_gpio_out(sms
->scp0
, SPITZ_SCP_LED_GREEN
,
898 qdev_get_gpio_in_named(miscdev
, "green-led", 0));
899 qdev_connect_gpio_out(sms
->scp0
, SPITZ_SCP_LED_ORANGE
,
900 qdev_get_gpio_in_named(miscdev
, "orange-led", 0));
901 qdev_connect_gpio_out(sms
->scp0
, SPITZ_SCP_ADC_TEMP_ON
,
902 qdev_get_gpio_in_named(miscdev
, "adc-temp-on", 0));
903 qdev_connect_gpio_out_named(miscdev
, "adc-temp", 0,
904 qdev_get_gpio_in(sms
->max1111
, MAX1111_BATT_TEMP
));
907 qdev_connect_gpio_out(sms
->scp1
, SPITZ_SCP2_BACKLIGHT_CONT
,
908 qdev_get_gpio_in_named(sms
->lcdtg
, "bl_bit5", 0));
909 qdev_connect_gpio_out(sms
->scp1
, SPITZ_SCP2_BACKLIGHT_ON
,
910 qdev_get_gpio_in_named(sms
->lcdtg
, "bl_power", 0));
914 #define SPITZ_GPIO_HSYNC 22
915 #define SPITZ_GPIO_SD_DETECT 9
916 #define SPITZ_GPIO_SD_WP 81
917 #define SPITZ_GPIO_ON_RESET 89
918 #define SPITZ_GPIO_BAT_COVER 90
919 #define SPITZ_GPIO_CF1_IRQ 105
920 #define SPITZ_GPIO_CF1_CD 94
921 #define SPITZ_GPIO_CF2_IRQ 106
922 #define SPITZ_GPIO_CF2_CD 93
924 static int spitz_hsync
;
926 static void spitz_lcd_hsync_handler(void *opaque
, int line
, int level
)
928 PXA2xxState
*cpu
= (PXA2xxState
*) opaque
;
929 qemu_set_irq(qdev_get_gpio_in(cpu
->gpio
, SPITZ_GPIO_HSYNC
), spitz_hsync
);
933 static void spitz_reset(void *opaque
, int line
, int level
)
936 qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET
);
940 static void spitz_gpio_setup(PXA2xxState
*cpu
, int slots
)
946 * Bad hack: We toggle the LCD hsync GPIO on every GPIO status
947 * read to satisfy broken guests that poll-wait for hsync.
948 * Simulating a real hsync event would be less practical and
949 * wouldn't guarantee that a guest ever exits the loop.
952 lcd_hsync
= qemu_allocate_irq(spitz_lcd_hsync_handler
, cpu
, 0);
953 pxa2xx_gpio_read_notifier(cpu
->gpio
, lcd_hsync
);
954 pxa2xx_lcd_vsync_notifier(cpu
->lcd
, lcd_hsync
);
957 pxa2xx_mmci_handlers(cpu
->mmc
,
958 qdev_get_gpio_in(cpu
->gpio
, SPITZ_GPIO_SD_WP
),
959 qdev_get_gpio_in(cpu
->gpio
, SPITZ_GPIO_SD_DETECT
));
961 /* Battery lock always closed */
962 qemu_irq_raise(qdev_get_gpio_in(cpu
->gpio
, SPITZ_GPIO_BAT_COVER
));
965 reset
= qemu_allocate_irq(spitz_reset
, cpu
, 0);
966 qdev_connect_gpio_out(cpu
->gpio
, SPITZ_GPIO_ON_RESET
, reset
);
968 /* PCMCIA signals: card's IRQ and Card-Detect */
970 pxa2xx_pcmcia_set_irq_cb(cpu
->pcmcia
[0],
971 qdev_get_gpio_in(cpu
->gpio
, SPITZ_GPIO_CF1_IRQ
),
972 qdev_get_gpio_in(cpu
->gpio
, SPITZ_GPIO_CF1_CD
));
974 pxa2xx_pcmcia_set_irq_cb(cpu
->pcmcia
[1],
975 qdev_get_gpio_in(cpu
->gpio
, SPITZ_GPIO_CF2_IRQ
),
976 qdev_get_gpio_in(cpu
->gpio
, SPITZ_GPIO_CF2_CD
));
980 #define SPITZ_RAM 0x04000000
981 #define SPITZ_ROM 0x00800000
983 static struct arm_boot_info spitz_binfo
= {
984 .loader_start
= PXA2XX_SDRAM_BASE
,
985 .ram_size
= 0x04000000,
988 static void spitz_common_init(MachineState
*machine
)
990 SpitzMachineClass
*smc
= SPITZ_MACHINE_GET_CLASS(machine
);
991 SpitzMachineState
*sms
= SPITZ_MACHINE(machine
);
992 enum spitz_model_e model
= smc
->model
;
994 MemoryRegion
*rom
= g_new(MemoryRegion
, 1);
996 /* Setup CPU & memory */
997 mpu
= pxa270_init(spitz_binfo
.ram_size
, machine
->cpu_type
);
1000 sl_flash_register(mpu
, (model
== spitz
) ? FLASH_128M
: FLASH_1024M
);
1002 memory_region_init_rom(rom
, NULL
, "spitz.rom", SPITZ_ROM
, &error_fatal
);
1003 memory_region_add_subregion(get_system_memory(), 0, rom
);
1005 /* Setup peripherals */
1006 spitz_keyboard_register(mpu
);
1008 spitz_ssp_attach(sms
);
1010 sms
->scp0
= sysbus_create_simple("scoop", 0x10800000, NULL
);
1011 if (model
!= akita
) {
1012 sms
->scp1
= sysbus_create_simple("scoop", 0x08800040, NULL
);
1017 spitz_scoop_gpio_setup(sms
);
1019 spitz_gpio_setup(mpu
, (model
== akita
) ? 1 : 2);
1021 spitz_i2c_setup(machine
, mpu
);
1024 spitz_akita_i2c_setup(mpu
);
1026 if (model
== terrier
)
1027 /* A 6.0 GB microdrive is permanently sitting in CF slot 1. */
1028 spitz_microdrive_attach(mpu
, 1);
1029 else if (model
!= akita
)
1030 /* A 4.0 GB microdrive is permanently sitting in CF slot 0. */
1031 spitz_microdrive_attach(mpu
, 0);
1033 spitz_binfo
.board_id
= smc
->arm_id
;
1034 arm_load_kernel(mpu
->cpu
, machine
, &spitz_binfo
);
1035 sl_bootparam_write(SL_PXA_PARAM_BASE
);
1038 static void spitz_common_class_init(ObjectClass
*oc
, void *data
)
1040 MachineClass
*mc
= MACHINE_CLASS(oc
);
1042 mc
->block_default_type
= IF_IDE
;
1043 mc
->ignore_memory_transaction_failures
= true;
1044 mc
->init
= spitz_common_init
;
1046 machine_add_audiodev_property(mc
);
1049 static const TypeInfo spitz_common_info
= {
1050 .name
= TYPE_SPITZ_MACHINE
,
1051 .parent
= TYPE_MACHINE
,
1053 .instance_size
= sizeof(SpitzMachineState
),
1054 .class_size
= sizeof(SpitzMachineClass
),
1055 .class_init
= spitz_common_class_init
,
1058 static void akitapda_class_init(ObjectClass
*oc
, void *data
)
1060 MachineClass
*mc
= MACHINE_CLASS(oc
);
1061 SpitzMachineClass
*smc
= SPITZ_MACHINE_CLASS(oc
);
1063 mc
->desc
= "Sharp SL-C1000 (Akita) PDA (PXA270)";
1064 mc
->default_cpu_type
= ARM_CPU_TYPE_NAME("pxa270-c0");
1066 smc
->arm_id
= 0x2e8;
1069 static const TypeInfo akitapda_type
= {
1070 .name
= MACHINE_TYPE_NAME("akita"),
1071 .parent
= TYPE_SPITZ_MACHINE
,
1072 .class_init
= akitapda_class_init
,
1075 static void spitzpda_class_init(ObjectClass
*oc
, void *data
)
1077 MachineClass
*mc
= MACHINE_CLASS(oc
);
1078 SpitzMachineClass
*smc
= SPITZ_MACHINE_CLASS(oc
);
1080 mc
->desc
= "Sharp SL-C3000 (Spitz) PDA (PXA270)";
1081 mc
->default_cpu_type
= ARM_CPU_TYPE_NAME("pxa270-c0");
1083 smc
->arm_id
= 0x2c9;
1086 static const TypeInfo spitzpda_type
= {
1087 .name
= MACHINE_TYPE_NAME("spitz"),
1088 .parent
= TYPE_SPITZ_MACHINE
,
1089 .class_init
= spitzpda_class_init
,
1092 static void borzoipda_class_init(ObjectClass
*oc
, void *data
)
1094 MachineClass
*mc
= MACHINE_CLASS(oc
);
1095 SpitzMachineClass
*smc
= SPITZ_MACHINE_CLASS(oc
);
1097 mc
->desc
= "Sharp SL-C3100 (Borzoi) PDA (PXA270)";
1098 mc
->default_cpu_type
= ARM_CPU_TYPE_NAME("pxa270-c0");
1099 smc
->model
= borzoi
;
1100 smc
->arm_id
= 0x33f;
1103 static const TypeInfo borzoipda_type
= {
1104 .name
= MACHINE_TYPE_NAME("borzoi"),
1105 .parent
= TYPE_SPITZ_MACHINE
,
1106 .class_init
= borzoipda_class_init
,
1109 static void terrierpda_class_init(ObjectClass
*oc
, void *data
)
1111 MachineClass
*mc
= MACHINE_CLASS(oc
);
1112 SpitzMachineClass
*smc
= SPITZ_MACHINE_CLASS(oc
);
1114 mc
->desc
= "Sharp SL-C3200 (Terrier) PDA (PXA270)";
1115 mc
->default_cpu_type
= ARM_CPU_TYPE_NAME("pxa270-c5");
1116 smc
->model
= terrier
;
1117 smc
->arm_id
= 0x33f;
1120 static const TypeInfo terrierpda_type
= {
1121 .name
= MACHINE_TYPE_NAME("terrier"),
1122 .parent
= TYPE_SPITZ_MACHINE
,
1123 .class_init
= terrierpda_class_init
,
1126 static void spitz_machine_init(void)
1128 type_register_static(&spitz_common_info
);
1129 type_register_static(&akitapda_type
);
1130 type_register_static(&spitzpda_type
);
1131 type_register_static(&borzoipda_type
);
1132 type_register_static(&terrierpda_type
);
1135 type_init(spitz_machine_init
)
1137 static bool is_version_0(void *opaque
, int version_id
)
1139 return version_id
== 0;
1142 static const VMStateDescription vmstate_sl_nand_info
= {
1145 .minimum_version_id
= 0,
1146 .fields
= (VMStateField
[]) {
1147 VMSTATE_UINT8(ctl
, SLNANDState
),
1148 VMSTATE_STRUCT(ecc
, SLNANDState
, 0, vmstate_ecc_state
, ECCState
),
1149 VMSTATE_END_OF_LIST(),
1153 static Property sl_nand_properties
[] = {
1154 DEFINE_PROP_UINT8("manf_id", SLNANDState
, manf_id
, NAND_MFR_SAMSUNG
),
1155 DEFINE_PROP_UINT8("chip_id", SLNANDState
, chip_id
, 0xf1),
1156 DEFINE_PROP_END_OF_LIST(),
1159 static void sl_nand_class_init(ObjectClass
*klass
, void *data
)
1161 DeviceClass
*dc
= DEVICE_CLASS(klass
);
1163 dc
->vmsd
= &vmstate_sl_nand_info
;
1164 device_class_set_props(dc
, sl_nand_properties
);
1165 dc
->realize
= sl_nand_realize
;
1166 /* Reason: init() method uses drive_get() */
1167 dc
->user_creatable
= false;
1170 static const TypeInfo sl_nand_info
= {
1171 .name
= TYPE_SL_NAND
,
1172 .parent
= TYPE_SYS_BUS_DEVICE
,
1173 .instance_size
= sizeof(SLNANDState
),
1174 .instance_init
= sl_nand_init
,
1175 .class_init
= sl_nand_class_init
,
1178 static const VMStateDescription vmstate_spitz_kbd
= {
1179 .name
= "spitz-keyboard",
1181 .minimum_version_id
= 0,
1182 .post_load
= spitz_keyboard_post_load
,
1183 .fields
= (VMStateField
[]) {
1184 VMSTATE_UINT16(sense_state
, SpitzKeyboardState
),
1185 VMSTATE_UINT16(strobe_state
, SpitzKeyboardState
),
1186 VMSTATE_UNUSED_TEST(is_version_0
, 5),
1187 VMSTATE_END_OF_LIST(),
1191 static void spitz_keyboard_class_init(ObjectClass
*klass
, void *data
)
1193 DeviceClass
*dc
= DEVICE_CLASS(klass
);
1195 dc
->vmsd
= &vmstate_spitz_kbd
;
1196 dc
->realize
= spitz_keyboard_realize
;
1199 static const TypeInfo spitz_keyboard_info
= {
1200 .name
= TYPE_SPITZ_KEYBOARD
,
1201 .parent
= TYPE_SYS_BUS_DEVICE
,
1202 .instance_size
= sizeof(SpitzKeyboardState
),
1203 .instance_init
= spitz_keyboard_init
,
1204 .class_init
= spitz_keyboard_class_init
,
1207 static const VMStateDescription vmstate_corgi_ssp_regs
= {
1208 .name
= "corgi-ssp",
1210 .minimum_version_id
= 2,
1211 .fields
= (VMStateField
[]) {
1212 VMSTATE_SSI_PERIPHERAL(ssidev
, CorgiSSPState
),
1213 VMSTATE_UINT32_ARRAY(enable
, CorgiSSPState
, 3),
1214 VMSTATE_END_OF_LIST(),
1218 static void corgi_ssp_class_init(ObjectClass
*klass
, void *data
)
1220 DeviceClass
*dc
= DEVICE_CLASS(klass
);
1221 SSIPeripheralClass
*k
= SSI_PERIPHERAL_CLASS(klass
);
1223 k
->realize
= corgi_ssp_realize
;
1224 k
->transfer
= corgi_ssp_transfer
;
1225 dc
->vmsd
= &vmstate_corgi_ssp_regs
;
1228 static const TypeInfo corgi_ssp_info
= {
1229 .name
= TYPE_CORGI_SSP
,
1230 .parent
= TYPE_SSI_PERIPHERAL
,
1231 .instance_size
= sizeof(CorgiSSPState
),
1232 .class_init
= corgi_ssp_class_init
,
1235 static const VMStateDescription vmstate_spitz_lcdtg_regs
= {
1236 .name
= "spitz-lcdtg",
1238 .minimum_version_id
= 1,
1239 .fields
= (VMStateField
[]) {
1240 VMSTATE_SSI_PERIPHERAL(ssidev
, SpitzLCDTG
),
1241 VMSTATE_UINT32(bl_intensity
, SpitzLCDTG
),
1242 VMSTATE_UINT32(bl_power
, SpitzLCDTG
),
1243 VMSTATE_END_OF_LIST(),
1247 static void spitz_lcdtg_class_init(ObjectClass
*klass
, void *data
)
1249 DeviceClass
*dc
= DEVICE_CLASS(klass
);
1250 SSIPeripheralClass
*k
= SSI_PERIPHERAL_CLASS(klass
);
1252 k
->realize
= spitz_lcdtg_realize
;
1253 k
->transfer
= spitz_lcdtg_transfer
;
1254 dc
->vmsd
= &vmstate_spitz_lcdtg_regs
;
1257 static const TypeInfo spitz_lcdtg_info
= {
1258 .name
= TYPE_SPITZ_LCDTG
,
1259 .parent
= TYPE_SSI_PERIPHERAL
,
1260 .instance_size
= sizeof(SpitzLCDTG
),
1261 .class_init
= spitz_lcdtg_class_init
,
1264 static const TypeInfo spitz_misc_gpio_info
= {
1265 .name
= TYPE_SPITZ_MISC_GPIO
,
1266 .parent
= TYPE_SYS_BUS_DEVICE
,
1267 .instance_size
= sizeof(SpitzMiscGPIOState
),
1268 .instance_init
= spitz_misc_gpio_init
,
1270 * No class_init required: device has no internal state so does not
1271 * need to set up reset or vmstate, and does not have a realize method.
1275 static void spitz_register_types(void)
1277 type_register_static(&corgi_ssp_info
);
1278 type_register_static(&spitz_lcdtg_info
);
1279 type_register_static(&spitz_keyboard_info
);
1280 type_register_static(&sl_nand_info
);
1281 type_register_static(&spitz_misc_gpio_info
);
1284 type_init(spitz_register_types
)